0.3.2 • Published 6 years ago

zmq-jsonrpc v0.3.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

zmq-jsonrpc

Bi-directional JSON-RPC 2.0 for ZeroMQ

Client-side RPC

This is the ordinary way for people to make remote call. A server could be connected by multiple clients, clientId will be passed when a call was received to provide a way for server to identify where those calls are from.

// SERVER SIDE
var zRPC = require('zmq-jsonrpc');

var path = "ipc://foobar"; // or tcp://host:port

var server = zRPC.bind(path);
server.calling('foo', function(params, clientId){
    return "bar";
});

// or later bind
var server = new zRPC();
server.calling('foo', function(params, clientId){
    return "bar";
});
server.bind(path);

// CLIENT SIDE

var client = zRPC.connect(path);
client.call('foo', {foo1:"bar1", foo2:"bar2"})
.done(function(ret){
    //onSuccess
}, function(err){
    //onFail  err = {code:xxx, message:xxx}
});

// or later connect
var client = new zRPC();
client.call('foo', {foo1:"bar1", foo2:"bar2"})
.done(function(ret){
    //onSuccess
}, function(err){
    //onFail  err = {code:xxx, message:xxx}
});
client.connect(path);

Server-side RPC

zmq-jsonrpc support RPC call from server side to client side, but you have to know clientId from previous client-side calls.

client.calling('foo', function(params) {
    return "bar";
});

server.call('foo', {foo1:"bar1", foo2:"bar2"}, clientId)
.done(function(ret){
    //onSuccess
}, function(err){
    //onFail  err = {code:xxx, message:xxx}
});
0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

8 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago