msgpack5rpc

Msgpack-RPC(v5 spec) implementation

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
msgpack5rpc
1441.1.06 years ago8 years agoMinified + gzip package size for msgpack5rpc in KB

Readme

msgpack5rpc

Msgpack-RPC(v5 spec) implementation. Based on the

msgpack5 package. See the specification for details.
Build Status

Installation

npm install --save msgpack5rpc

Usage

This package exports a single class which represents a msgpack-rpc session. A Session instance can attached to any pair of write/read streams, and can send and receive requests and notifications, so it can be used for both client and servers. Example:
var Session = require('msgpack5rpc');

var session = new Session();
session.attach(process.stdout, process.stdin);
session.on('request', function(method, args, resp) {
  resp.send('response!');
  console.log('received request');
  session.request('remote-method', ['arg1', 'arg2'], function(err, res) {
    console.log('received response');
  });
});
session.on('notification', function(method, args) {
  console.log('received notification');
  session.notify('remote-event', ['arg1', 'arg2']);
});

See the "examples" subdirectory for a complete client/server implementation.