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.
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.
npm install jsonrpc-hub
- 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
makes use of unify-config, so
all the API options are available as command line arguments or environment
variables.
jsonrpc-hub --allowBroadcast --timeout 5000