0.0.0 • Published 6 years ago

jsonrpc-hub v0.0.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
6 years ago

JsonRPC hub

This server allow to relay bidirectional JsonRPC messages between clients connected to it. The protocol use a extension of the standard JsonRPC 2.0 with the addition of a to field to indicate the identifier of the destination client. This makes it transparent to the parameters given to the calls. It also provides support to send messages in broadcast by setting null as its value.

How it works

This module export a function that when called will generate a handler function for the connection event of the WebSocket server objects created with the ws module.

Internally, connections are registered so incoming data can be send to the corresponding destination. Destination is identified with a to field, besides that data are plain JsonRPC messages.

Install

npm install jsonrpc-hub

API

  • options
    • allowBroadcast: enable to send messages to all the other connections
    • getId: function to get the connection identifier. By default, it's used the connection url.
    • timeout: milliseconds before a request is responsed as failed. Disabled by default

CLI

cli makes use of unify-config, so all the API options are available as command line arguments or environment variables.

jsonrpc-hub --allowBroadcast --timeout 5000
0.0.0

6 years ago