Tiny RPC client/server library over Socket.IO.
DISCLAIMER This library is experimental. Use at your own risk.
Provides the most basic RPC functionality over Socket.IO. It supports invoking remote functions both on server and on client. Library is baked on Promises, so every remote call returns Promise of result.
It currently requires Node.js >=4.0.0. Since it utilizes ES6 features. Use babel
if you want to run it on older
versions of Node.js.
npm install git+https://[email protected]/NextHub/socket.io-tinyrpc.git
var RPCServer = require('socket.io-tinyrpc');
var server = new RPCServer({
double: (num) => 2 * num
});
server.listen(4000);
var RPCClient = require('socket.io-tinyrpc/client');
var client = new RPCClient();
client.connect('http://localhost:4001')
.then((exports) => exports.double(8))
.then((result) => console.log(result));
Browser build requires following points to be satisfied:
socket.io-client
as anio
global variable (if you're using AMD modules just install it as dependency)Promise
implementation as aPromise
global variable- ES6
Map
implementation as aMap
global variable
See examples/
folder for examples.