0.0.4 • Published 8 months ago
jsonrpc-bridge v0.0.4
jsonrpc-bridge
Remote procedure call (RPC) library for JavaScript. It is based on JSON-RPC 2.0 specification.
Installation
npm install --save jsonrpc-bridge
Usage
Server side
import * as testModule from './testModule';
const serverChannel: JSONRPCServerChannel = ...;
const server = new JSONRPCServer(serverChannel, { debug: true });
server.addModule('testModule', modules);
Client side
const clientChannel: JSONRPCClientChannel = ...;
const client = new JSONRPCClient<typeof modules>(clientChannel, { debug: true });
const res = await client.call.testModule.testMethod('test', 123) // call remote method
client.notify.testModule.testMethod('test', 123) // call remote method without response