demande
a client-side implementation of JSON-RPC 2.0 over websockets
Installation
$ npm install demande
Usage
const ws = 'ws://localhost:8080'ws rpc const trueFriend = "she gives what is hard to give" "she does what is hard to do" "she endures what is hard to endure" "she reveals their secrets to ye" "she keeps ye secrets" "when misfortunes strike, she doesn't abandon ye" "when ye're down and out, she doesn't look down on ye" { rpcws}
API
.fetch()
Builds a JSON-RPC request string with a unique id and sends it over the provided sockets. Stores the request with it's callback so it can be retrieved when the response comes back.
// rpc.fetch(method: str, params: obj, cb: function) -> (socket: WebSocket) -> nullrpcws
.resolve()
Parses every web socket message and executes any callback associated with the response.
// rpc.resolve(data: str) -> nullws
.getPending()
Returns a list of pending requests. Used mainly for testing purposes. Read-only.
// rpc.getPending() -> arr