Overview
Nisper is a RPC lib based on websocket protocol and nisp language.
Features
- Script based call makes the functions composable, you can even write a complex program to remote
- Safe by design, full control of the user's authority
- Same api for both node to browser, browser to node and node to node
- Full support for Promise calls
- Supports binary data type (json by default)
- Bidirectional communication
- Auto reconnect
Example
For more usage, read the unit test test/index.js
.
Live Demo: https://runkit.com/ysmood/nisper2
Echo Example
Node Server:
;; const server = ;
Browser or node client:
; const client = ; // add(1, add(1, 1))clientcallx`(+ 1 (+ 1 1))`;
Composable async function & msgpack
;;; const server = ;
Browser or node client:
;; const client = ; // add(1, add(1, 1))client;
API
nisper = // node native http.Server httpServer: null // string, such as `ws://a.com` url: null sandbox: {} env env Error isAutoReconnect: true retrySpan: 1000 timeout: 1000 * 60 * 2 String || Buffer Object // Same options as ws: https://github.com/websockets/ws/blob/master/doc/ws.md wsOptions: Object isDebug: false sandbox: Object close: Function websocketClient: Object websocketServer: Object middleware: Function call: Function;
call only once
var call = ; ;