Skip to content

KlausTrainer/snappy-msgpack-channels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

Stars

Watchers

Forks

Packages

No packages published