snappy-msgpack-channels

1.0.1 • Public • Published

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

/snappy-msgpack-channels/

    Package Sidebar

    Install

    npm i snappy-msgpack-channels

    Weekly Downloads

    3

    Version

    1.0.1

    License

    ISC

    Last publish

    Collaborators

    • klaus_trainer