multiplex-rpc-streams
RPC with streams using multiplex
Example
var rpc =var server =var client = rpcclientclientclient
Usage
rpc(methods={})
Each method can accept any number of expected arguments understanding that the last argument will always be a stream to respond to. This is a normal node stream that can be written or piped to.
var server =
rpc.client(methodNames=[])
Provide an array of method names which will be exposed as methods on the returned client
.
var client = rpcclient
You can also provide the method names as individual String
arguments
var client = rpc
Connecting the streams
The return value of rpc()
and rcp.client()
are both duplex streams which can be piped together to make the magic happen. See substack/stream-handbook#duplex and this rant by dominictarr for further information.
client
To expose these streams over the network you can use the listen
and connect
methods. Both accept port/host/path/callback arguments. See parse-connection-args for documentation.
var server =servervar client = rpcclient
License
MIT