How to use the rpc-websockets.Server function in rpc-websockets

To help you get started, we’ve selected a few rpc-websockets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pfrazee / nodevms / lib / vm / rpc-server.js View on Github external
constructor (backendVM, opts={}) {
    // setup the WebSocket server
    this.backendVM = backendVM
    this.server = new WebSocketServer({
      port: opts.port || DEFAULT_PORT
    })
    this.isReadyPromise = new Promise((resolve, reject) => {
      this.server.on('listening', resolve)
      this.server.on('error', reject)
    })

    // establish the method handlers
    this.registerCommands()
    this.callQueue = [] // backlog of RPC requests
    this.activeCall = null // call currently being processed
  }
github leapdao / leap-node / src / api / jsonrpc.js View on Github external
listenWs: ({ host, port }) => {
      const wsServer = new WsJsonRpcServer({
        port: port || 8646,
        host: host || 'localhost',
      });

      // register an RPC method
      Object.keys(nodeApi).forEach(key => {
        wsServer.register(key.toString(), withParams(nodeApi[key]));
      });

      return new Promise(resolve => {
        wsServer.on('listening', () => {
          return resolve({
            address: wsServer.wss.options.host,
            port: wsServer.wss.options.port,
          });
        });
github AraiEzzra / DDKCORE / backlog / api / rpc / server.js View on Github external
constructor() {
        this.registered = {};
        this.port = port;
        this.host = host;
        this.path = `/v${version}`;

        this.webSocketServer = new WebSocketServer({
            port: this.port,
            host: this.host,
        });
    }
github AraiEzzra / DDKCORE / shared / util / rpc.ts View on Github external
initServer(host?: string, port?: number) {
       host = host ? host : this.host;
       port = port ? port : this.port;
       this.rpcNode = new WebSocketServer({
           port: port,
           host: host
       });
    }

rpc-websockets

JSON-RPC 2.0 implementation over WebSockets for Node.js

LGPL-3.0-only
Latest version published 2 months ago

Package Health Score

80 / 100
Full package analysis

Popular rpc-websockets functions