rpc with multiplexed duplex streams
JavaScript
Latest commit f979fbe May 28, 2015 @substack 1.0.1
Permalink
Failed to load latest commit information.
example
test
LICENSE
index.js
package.json
readme.markdown

readme.markdown

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