jsonrpc-node-commit
JSON RPC client/server with multiple transport types : TCP, HTTP, Middleware and SSL support
Last updated 2 years ago by kenhuang .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install jsonrpc-node-commit 
SYNC missed versions from official npm registry.

##JsonRPC-Node Multi transport JSON-RPC client/server with SSL support for node.js

Can be used as stand alone server or as net.Server/express middleware

###installation

npm install jsonrpc-node

###server

Include library

Server = require("jsonrpc-node").TCP.Server;

or over http

Server = require("jsonrpc-node").HTTP.Server;

Create server object

var server = new Server({echo:function(args, reply){return reply(args);}});

or without arguments

var server = new Server();

Register some methods

server.register("ping", function(args, reply){
    reply("pong");
    reply.notify("pong2"); //data can be streamed
});

or bulk register

server.register({ping:function(args, reply){reply("pong");}, time:function(args, reply){return reply.error("some error");}});

Start listening

server.listen(3001, "localhost")

or use SSL connection

server.listenSSL(3001, "localhost","key.pem","cert.pem");

or can be used as middleware,

tcp server for net.Server

net.createServer(server)

http server for express

var app = express();
app.use("/api", server);

###client

Include library

Client = require("jsonrpc-node").TCP.Client;

or

Client = require("jsonrpc-node").HTTP.Client;

Create client object

client = new Client(3001, "localhost");

Execute remote methods

client.call("multiply", [1,2,4], function(err, result){})

Current Tags

  • 1.2.93                                ...           latest (2 years ago)

1 Versions

  • 1.2.93                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |