Multiplexed negotiated streams of framed Snappy-compressed MessagePack messages.
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
}
});
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'});
}
});
snappy-msgpack-channels has been heavily inspired by:
- pipe-channels by Pedro Teixeira
ISC