当前位置: 首页 > 软件库 > 云计算 > Serverless 系统 >

rpc-websockets

授权协议 View license
开发语言 JavaScript
所属分类 云计算、 Serverless 系统
软件类型 开源软件
地区 不详
投 递 者 窦弘义
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

WebSockets for Node.js and JavaScript/TypeScript with JSON RPC 2.0 support on top.




About

The rpc-websockets library enables developers to easily implement their business logic that includes messaging between users, machines or any devices. It provides a possibility to send and receive JSON data through the WebSocket communication protocol in order to support two-way notification push, running RPC methods and firing any types of event signalling. Only clients can call RPC methods and not vice versa at the moment. Both frontend (HTML/JS-based) and backend (Node.js-based) development environments are supported.

rpc-websockets is built on Node.js and supports both LTS and Current versions.

Use the free OSS edition in order to implement and manage your own WebSocket server instances, or subscribe for our Pro plan and have us manage your instances and provide you with management of your methods, events and notifications on an easy-to-use Web Management portal.

Quick start

Install our OSS library in your project:

npm install rpc-websockets

Write your source code using rpc-websockets:

var WebSocket = require('rpc-websockets').Client
var WebSocketServer = require('rpc-websockets').Server

// instantiate Server and start listening for requests
var server = new WebSocketServer({
  port: 8080,
  host: 'localhost'
})

// register an RPC method
server.register('sum', function(params) {
  return params[0] + params[1]
})

// ...and maybe a protected one also
server.register('account', function() {
  return ['confi1', 'confi2']
}).protected()

// create an event
server.event('feedUpdated')

// get events
console.log(server.eventList())

// emit an event to subscribers
server.emit('feedUpdated')

// close the server
server.close()

// instantiate Client and connect to an RPC server
var ws = new WebSocket('ws://localhost:8080')

ws.on('open', function() {
  // call an RPC method with parameters
  ws.call('sum', [5, 3]).then(function(result) {
    require('assert').equal(result, 8)
  })

  // send a notification to an RPC server
  ws.notify('openedNewsModule')

  // subscribe to receive an event
  ws.subscribe('feedUpdated')

  ws.on('feedUpdated', function() {
    updateLogic()
  })

  // unsubscribe from an event
  ws.unsubscribe('feedUpdated')

  // login your client to be able to use protected methods
  ws.login({'username': 'confi1', 'password':'foobar'}).then(function() {
    ws.call('account').then(function(result) {
      require('assert').equal(result, ['confi1', 'confi2'])
    })
  }).catch(function(error) {
    console.log('auth failed')
  })

  // close a websocket connection
  ws.close()
})

Documentation

Please consult our API documentation for both WebSocket server and client JavaScript and TypeScript classes.

OSS Features

Features of the free open-source edition.

All library's open-source features are documented in our API documentation and can be used free of charge. You are free to implement your solutions based on provided methods in any way you are comfortable with, as long as you use our work along our very permissive license conditions.

Pro Features

In order to support your production-ready environments, we can provide you with additional features built on top of our free OSS edition along with the skill set to turn your business case or a Proof-of-Concept idea into reality.

Describe us your use case by contacting us and we will swiftly get back to you with a proposed solution that meets your needs.

Professional support

We offer professional support for rpc-websockets and beyond. We have many years of expertise on building robust, scalable Node.js applications and can help you overcome issues and challenges preventing you to ship your great products. We excel in software architecture and implementation, being able to provide you with development, planning, consulting, training and customization services. Feel free to contact us so we can discuss how to help you finish your products!

Users

rpc-websockets is being actively used in production by multiple companies in a variety of different use cases.


ScratchboxLoom NetworkuniqCastLeapDAOKlika Tech, Inc.Kodebox, Inc.Hey-Group S.A./N.V.Hylo, Inc.Witnet FoundationScale LeapCodice Foundation, Inc.Holo Ltd.Solana Labs, Inc.Filecoin

Sponsors

Become a sponsor and get your logo on project's README on GitHub with a link to your site. Feel free to contact us for the arrangement!

License

This library is licensed under LGPLv3. Please see LICENSE for licensing details.

  • websockets In my previous article, How to think reactively and animate moving objects using RxJs, I described how to build a MobileObject class that simulates the movement of an object subject to acce

  • JSON-RPC Endpoint Available Resources Mainnet(ChainID 0x38, 56 in decimal) BSC RPC Endpoints: Note You can make eth_getLogs requests with up to a 5K block range. If you need to pull logs frequently, w

  • 背景 当一个目标站加密字段特别多,而且我们对其并不需要大规模爬取时,考虑到时间成本,我们就可以使用RPC来获取加密数据。 RPC: 远程服务器调用, 原理简单的说就是 搭建一个后端服务器, 然后把拦截到的浏览器数据通过websocket发送到我们的服务器, 我们通过API 取获取加密数据。 这里就不多说了, 想详细了解的自行取goole吧! 今天我所带来的是一个简单的RPC模型, 架构很简单,主要

  • JSON-RPC 端点 可用资源 主网(ChainID 0x38,十进制56) BSC RPC 端点: 笔记 您可以发出eth_getLogs最多 5K 块范围的请求。如果您需要频繁拉取日志,我们建议您使用 WebSockets 在新日志可用时将其推送给您。 推荐 https://bsc-dataseed.binance.org/ https://bsc-dataseed1.defibit.io/

  • 这是一个术语词汇表,经常出现在关于多媒体传输的讨论中。大多数术语都被描述并链接到维基百科、RFC或W3C相关文档。有些术语是kurento特有的。 HTTP 超文本传输协议是一种适用于分布式、协同、超媒体信息系统的应用协议。http是万维网数据通信的基础。 另外可以参考:RFC 2616 JAVA Java是一种通用的计算机编程语言,它是并发的、基于类的、面向对象的,并且专门设计成尽可能少的实现依

 相关资料
  • Flex提供RPC服务以向客户端提供服务器端数据。 Flex为服务器端数据提供了相当大的控制。 使用Flex RPC服务,我们可以定义要在服务器端执行的用户操作。 Flex RPC Sservices可以与任何服务器端技术集成。 其中一个Flex RPC服务提供内置支持,可以通过线路传输压缩二进制数据,速度非常快。 Flex提供以下三种类型的RPC服务 S.No RPC服务和描述 1 HttpSe

  • 基于GWT的应用程序通常由客户端模块和服务器端模块组成。 客户端代码在浏览器中运行,服务器端代码在Web服务器中运行。 客户端代码必须在网络上发出HTTP请求才能访问服务器端数据。 RPC,远程过程调用是GWT使用的机制,其中客户端代码可以直接执行服务器端方法。 GWT RPC是基于servlet的。 GWT RPC是异步的,客户端在通信期间从不被阻止。 使用GWT RPC Java对象可以直接在

  • RPC

    RPC文档托管在这里: https://tendermint.com/rpc/ 若要更新文档,可以在 rpc/core 目录 编辑相关的 godoc 注释。

  • RPC

    JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs. JSON-RPC is a stateless, light-weight remote procedu

  • rpc

    rpc agentnotifiers 主要负责发出一些rpc的通知给agent,包括三个文件:dhcp_rpc_agent_api.py、l3_rpc_agent_api.py、metering_rpc_agent_api.py。 分别实现向dhcp、l3或者metering的agent发出通知消息。 以dhcp_rpc_agent_api.py为例,定义了DhcpAgentNotifyAPI类,

  • RPC

    前面几个小节我们介绍了如何基于Socket和HTTP来编写网络应用,通过学习我们了解了Socket和HTTP采用的是类似"信息交换"模式,即客户端发送一条信息到服务端,然后(一般来说)服务器端都会返回一定的信息以表示响应。客户端和服务端之间约定了交互信息的格式,以便双方都能够解析交互所产生的信息。但是很多独立的应用并没有采用这种模式,而是采用类似常规的函数调用的方式来完成想要的功能。 RPC就是想