snappy-msgpack-channels
v1.0.1
Published
Multiplexed negotiated streams of framed Snappy-compressed MessagePack messages.
Downloads
3
Maintainers
Readme
snappy-msgpack-channels
Multiplexed negotiated streams of framed Snappy-compressed MessagePack messages.
Usage
Server
var snappyChannels = require('snappy-msgpack-channels');
var server = snappyChannels.createServer();
// listen for new channel requests
server.on('request', function(req) {
// req.payload can be arbitrary values passed in by the client
if (req.payload.token == '1234') {
req.grant(); // grant the channel
} else {
req.deny('access denied'); // deny the channel
}
});
Client
var snappyChannels = require('snappy-msgpack-channels');
var client = snappyChannels.createClient();
// ask for a channel, passing in any arbitrary payload
client.channel({token: '1234'}, function(err, channel) {
if (err) {
console.error('could not get a channel because', err.message);
} else {
channel.write({hello: 'world'});
}
});
Acknowledgments
snappy-msgpack-channels has been heavily inspired by:
- pipe-channels by Pedro Teixeira
License
ISC