KlausTrainer / snappy-msgpack-channels

Multiplexed negotiated streams of framed Snappy-compressed MessagePack messages

Home Page:https://www.npmjs.com/package/snappy-msgpack-channels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

snappy-msgpack-channels

Build Status JavaScript Style Guide semantic-release

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:

License

ISC

About

Multiplexed negotiated streams of framed Snappy-compressed MessagePack messages

https://www.npmjs.com/package/snappy-msgpack-channels


Languages

Language:JavaScript 100.0%