call.io
v1.1.0
Published
A remote procedure call system through Socket.IO
Downloads
1
Readme
Call.IO
A remote procedure call (RPC) module through Socket.IO.
Installation
npm install -s call.io
or :
yarn add call.io
Usage
You can see a use case in /example
, here is an example.
Server side
const server = require('http').createServer();
const io = require('socket.io')(server);
const callio = require('callio');
const methods = {
log: message => {
console.log(message);
return "Hello from server";
},
plusOne: value => value + 1
};
io.on('connection', socket => callio.publish(socket, "methods", methods));
server.listen(8080);
Client side
(async () => {
const socket = require('socket.io-client')('http://127.0.0.1:8080/');
const callio = require('callio');
const { log, plusOne } = await callio.require(socket, "methods");
console.log(await log("Hello from client"));
console.log(await plusOne(10));
})();
License
Call.IO is released under the MIT License. See LICENSE for more information.