Class: Client

Client


new Client( [server] [, options])

Constructor for a Jayson Client
Parameters:
Name Type Argument Description
server Server <optional>
An instance of Server (a object with a "call" method")
options Object <optional>
Properties
Name Type Argument Default Description
reviver function <optional>
Reviver function for JSON
replacer function <optional>
Replacer function for JSON
version Number <optional>
2 JSON-RPC version to use (1|2)
generator function <optional>
Function to use for generating request IDs
Source:
Returns:
Type
Client

Extends

  • require('events').EventEmitter

Members


<static> browser :ClientBrowser

Browser client constructor
Type:
Source:

<static> http :ClientHttp

HTTP client constructor
Type:
Source:

<static> https :ClientHttps

HTTPS client constructor
Type:
Source:

<static> tcp :ClientTcp

TCP client constructor
Type:
Source:

<static> tls :ClientTls

TLS client constructor
Type:
Source:

Methods


request(method, params [, id] [, callback])

Creates a request and dispatches it if given a callback.
Parameters:
Name Type Argument Description
method String | Array A batch request if passed an Array, or a method name if passed a String
params Array | Object Parameters for the method
id String | Number <optional>
Optional id. If undefined an id will be generated. If null it creates a notification request
callback function <optional>
Request callback. If specified, executes the request rather than only returning it.
Source:
Throws:
Invalid parameters
Type
TypeError
Returns:
JSON-RPC 1.0 or 2.0 compatible request
Type
Object