multiplex-stream
Multiplex multiple streams through a single stream
Features
- should provide multiple readable/writable streams over a single carrier stream
- should behave correctly with intermediate flow control where data events may get split and/or concatenated
- should allow the downstream connection to write data first
- should allow a stream to be named
- should error if the upstream multiplex already has a connection with the requested name
- should timeout if no multiplex responds to connect requests
- should timeout connect requests if the downstream multiplex already has a connection with the requested name as multicasting to more than one multiplex is not a supported use case
- should end tunnel streams cleanly when the multiplex stream ends
Installation
npm install stream-multiplex
API
var MultiplexStream = ; // create downstream multiplex that listens for connectionsvar downstreamMultiplex = { // a multiplexed stream has connected from upstream. // The assigned id will be accessible as downstreamConnection.id downstreamConnection; downstreamConnection; downstreamConnection;}; // create upstream multiplex that will be used to initiate connectionsvar upstreamMultiplex = // The connectTimeout optionally specifies how long to // wait in milliseconds for the downstream multiplex to // accept to connections. It defaults to 3000 milliseconds connectTimeout: 5000; // pipe from one multiplex to the other (there could// be other carrier streams in between, for instance a net socket)upstreamMultiplex; // create a new upstream multiplexed streamvar upstreamConnection = upstreamMultiplex;
Roadmap
- Nothing at this time
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using ./grunt.sh
or .\grunt.bat
.
License
Copyright (c) 2012 Peter Halliday
Licensed under the MIT license.