multiplex-rpc
v1.0.1
Published
rpc with duplex streams using multiplex
Downloads
14
Readme
multiplex-rpc
rpc with multiplexed duplex streams
like rpc-with-streams but using multiplex instead of mux-demux
example
server:
var RPC = require('multiplex-rpc');
var net = require('net');
var fs = require('fs');
var server = net.createServer(function (stream) {
var rpc = RPC({
hello: function () {
return fs.createReadStream(__dirname + '/hello.txt');
}
});
stream.pipe(rpc).pipe(stream);
});
server.listen(5000);
client:
var RPC = require('multiplex-rpc');
var net = require('net');
var rpc = RPC();
rpc.pipe(net.connect(5000)).pipe(rpc);
var client = rpc.wrap([ 'hello:s' ]);
client.hello().pipe(process.stdout);
methods
var RPC = require('multiplex-rpc')
var rpc = RPC(api)
Create a new rpc duplex stream instance rpc
that wraps the interface api
similarly to rpc-stream.
var client = rpc.wrap(methods)
Create an interface client
based on methods
, an array of string method
names. Method names that end with :s
are interpreted as duplex stream methods.
install
With npm do:
npm install multiplex-rpc
license
MIT