rpc-duplex
Streamed RPC library for both Node.JS and the browser
Important notes
This implementation DOES NOT follow any generic RPC specification as far as I know. It intends to provide a stable stand-alone solution for remote-procedure-calling over websockets in both Node.JS and the browser.
Install
npm install --save rpc-duplex
Usage
Node.JS
const rpc = ; // Creating a providerconst provider = ; // Creating a consumerconst consumer = ; // Connect consumer & provider// Normally this goes through a network of sortsprovider; // Use provided functionsconst remote = rpc; // Go async so you can copy-paste this codeasync { // Wait for functions to appear whileremotecapitalize await ; // Call a remote function let result = await remote; console; // FOOBAR // Errors are re-thrown try await remote; catche console; // hello world };
Browser
Browser usage is possible through the use of browserify (webpack should be supported but is not tested).
This package makes use of ES6 features. If you want to use this module in older browsers you'll need to use a plugin like esmify to ensure it works.