tcp-stream-muxer
This library enables you to send multiple Streams over one connection. It uses Buffers to send data on the TCP channel. So the overhead is minimal.
To create a MuxServer (tcp server):
var Muxer = ;var server = 12345;
To create a MuxClient (tcp client):
var Muxer = ;var server = 12345;
The MuxServer is an EventEmitter with following events:
- connection - Emits when a new Client connects to a MuxServer
The connection also is an EventEmitter:
- stream - Emits if the Client creates a new Stream
Each Stream has a EventEmitter:
- data - The data that comes out of the stream
- end - If the Stream gets terminated
Each one, the Server and the Client, have a StreamPool per Connection. To access it you need a connection on the server. Creating new Streams in tcp-stream-muxer:
Server:
var Muxer = ;var server = 12345;server
The client that accepts this stream:
var Muxer = ;var client = 12345 { client;
Client:
var Muxer = ;var client = 12345 { clientStreamPool;};
The server that accepts this stream:
var Muxer = ;var server = 12345;server
Changelog: v0.1.0:
- Fixing a bug where pipe chaining breaks
- Fixed a typo in the Package description
v0.0.7:
- Piping error and close events through the client.
- Fixed a bug where the maximum amount of streams is not 255
- Added Test case: streamOverflow.js - Create streams, the client should crash if more than 255 streams are alive, the server should run
v0.0.6:
- Fixed memory leakage, holding Buffer too long is not good :D
- Added Test case: overhead.js - Showing how much overhead the muxer is producing
- Added Test case: leakage.js - Showing the heapUsed bytes during sending data
v0.0.5:
- Fixed a bug where i keep getting wrong buffer slices (very rare bug :D)
v0.0.4:
- Removed the return from the StreamPool. If you want to have the stream you must have an ack callback. It gets the stream.
- Added a connected callback to the client. It gets called if a connection is ready to go
- Finally added the util file. Forgot it sry.....
v0.0.3:
- Added utilities for sending Files over a stream. Accessible via require('tcp-stream-muxer').util.
- Added the util Function sendFile(filename, stream) to send the file filename over the stream stream
- Added the util Function receiveFile(filename, stream) to receive the file from the stream and save them to filename
- Added a second parameter to the createStream function. It is a callback that gets fired when the other site has created the stream.