peerjs-rpc
RPC module for WebRTC using peerjs.
Installation
npm install peerjs-rpc
Usage
ping(nodeId, callback)
Calls callback with either true
or false
.
attr(nodeId, attrName, callback)
Calls callback with (err, result)
, where result is the attribute in the given scope on the remote node.
invoke(nodeId, functionName, arguments, callback)
Calls callback with (err, result)
, where result is the value returned by the callback given to the function in the given scope on the remote node. arguments
can be one argument or an array with arguments.
Examples
Javascript
var RPC = ;var scope = { return ; } 'answer': 42; var rpc = 'node-id' scope;var rpc2 = 'another-node' scope; rpc ;// => true rpc ;// => hi there R2! rpc ;// => 42
Bailey.js
import peerjs-rpc as RPC scope = : callback"hi there !" answer: 42 rpc = 'node-id'scoperpc2 = 'another-node'scope # running on another node rpcping'another-node'then consoleloganswer# => true rpcinvoke'another-node''hi''R2'then consoleloganswer# => hi there R2! rpcattr'another-node''answer'then consoleloganswer# => 42
MIT © Rolf Erik Lekang