rpc with duplex streams using multiplex
npm install multiplex-rpcrpc with multiplexed duplex streams
like rpc-with-streams
but using multiplex instead of mux-demux
server:
`` js
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:
` js
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);
`
` js`
var RPC = require('multiplex-rpc')
Create a new rpc duplex stream instance rpc that wraps the interface api
similarly to rpc-stream.
Create an interface client based on methods, an array of string method:s
names. Method names that end with are interpreted as duplex stream methods.
With npm do:
```
npm install multiplex-rpc
MIT