Module: fathom/proto/jsonrpc

JSONRPC protocol implementation with Fathom sockets (tcp/udp) or using HTTP (XMLHttpRequest). Client side can use all three protocols, local server only supports UDP for now.
Source:

Methods

(static) close(callback, id)

Close server/client.
Parameters:
Name Type Description
callback function The return callback. Returns an object with error field in case of failure.
id integer The JSONRPC object id returned from the 'create' API.
Source:

(static) create(callback, dst, port, server, proto, path)

This function creates and returns a JSONRPC object.
Parameters:
Name Type Description
callback function The return callback. Returns the object id or an object with error field in case of failure.
dst string The destination IP if client else acts as server.
port int The destination port (or listen port for server).
server boolean Server mode ? (default false).
proto string One of 'udp' (default), 'multicast', 'tcp' (cli only) or 'http' (cli only).
path string Url base path (http only - default /).
Source:

(static) listen(callback, id)

Listen for incoming requests (server only).
Parameters:
Name Type Description
callback function The return callback. Returns an object with error field in case of failure.
id integer The JSONRPC object id returned from the 'create' API.
Source:

(static) makereq(callback, id, method, params, module, urlparams)

Make a RPC request (client only).
Parameters:
Name Type Description
callback function The return callback. Returns an object with error field in case of failure.
id integer The JSONRPC object id returned from the 'create' API.
method string The JSONRPC method to call.
params Array The parameters for the RPC call.
module string The URL module path (http request only, optional).
urlparams string The URL params (http request only, optional).
Source:

(static) sendres(callback, id, res, error)

Send response to incoming requests (server only).
Parameters:
Name Type Description
callback function The return callback. Returns an object with error field in case of failure.
id integer The JSONRPC object id returned from the 'create' API.
res object The req object with added result field (empty if error)
error string Error code in case of failure (else undefined).
Source: