muxpit

0.2.0 • Public • Published

muxpit

minimal multiplex interface using rpc-stream.

example

var muxpit = require('muxpit');
var concat = require('concat-stream');
var net = require('net');
 
var server = net.createServer(function (stream) {
  var pit = muxpit(function (stream, id) {
    stream.end('warp riders');
  });
  stream.pipe(pit).pipe(stream);
});
 
server.listen(0, function () {
  var client = net.connect(server.address().port);
 
  var pit = muxpit();
  pit.pipe(client).pipe(pit);
 
  var stream = pit.open('some-id');
  stream.pipe(concat(function (body) {
    console.log(body.toString());
  }));
});

api

var muxpit = require('muxpit')

var pit = muxpit([opts], [onchannel])

Returns a multiplex.

  • opts and onchannel are same as that of multiplex

pit.open(id, [opts])

Creates and returns a shared stream. opts are same as that of multiplex.createSharedStream() and will be applied to both local and remote streams.

This method also emits an open event with (stream, id) at the other end.

license

mit

Readme

Keywords

none

Package Sidebar

Install

npm i muxpit

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • tetsuo