multiplex-rpc
rpc with duplex streams using multiplex
Last updated 5 years ago by substack .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install multiplex-rpc 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.1                                ...           latest (5 years ago)

2 Versions

  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (3)

Copyright 2014 - 2017 © taobao.org |