rpcsocketlib

0.0.3 • Public • Published

rpcsocketlib

install

yarn add rpcsocketlib

server.js

const { socketServer } = require('rpcsocketlib');

(async () => {
  await socketServer(4001);
})();

provider.js

const { socketConsume } = require('rpcsocketlib');

socketConsume('http://localhost:4001', 'test-channel', async (body) => {
  console.log(body);
  return body;
});

consumer.js

const { socketRequest } = require('rpcsocketlib');

(async () => {
  const res = await socketRequest('http://localhost:4001', 'test-channel', { message: 'surprise motherfucker' });
  console.log(res);
})();

usage

socketRequest (uri, channel, body, config)

  • uri : socket server url, ex : http://localhost:4001
  • channel : target client channel
  • body : data, type : object
  • config : options [timeout : int , noReply : bool]

socketConsume (uri, channel, cb)

  • uri : socket server url, ex : http://localhost:4001
  • channel : incoming data channel
  • cb : callback, ex : cb(body) {}

/rpcsocketlib/

    Package Sidebar

    Install

    npm i rpcsocketlib

    Weekly Downloads

    0

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    5.76 kB

    Total Files

    9

    Last publish

    Collaborators

    • certug