Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cedrictailly/call.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Call.IO

npm version License: MIT

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

This package is open source and available under the MIT License.

About

A remote procedure call system through Socket.IO

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published