Skip to content

Multi transport tcp/http/middleware JSON-RPC client/server with SSL support for node.js

License

Notifications You must be signed in to change notification settings

devktor/jsonrpc-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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){})

About

Multi transport tcp/http/middleware JSON-RPC client/server with SSL support for node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •