Documentation

Request extends Message
in package

A rpc call is represented by sending a Request object to a Server

Table of Contents

Properties

$id  : int|string
An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be NULL and Numbers SHOULD NOT contain fractional parts.
$jsonrpc  : string
A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0".
$method  : string
A String containing the name of the method to be invoked. Method names that begin with the word rpc followed by a period character (U+002E or ASCII 46) are reserved for rpc-internal methods and extensions and MUST NOT be used for anything else.
$params  : object|array<string|int, mixed>|null
A Structured value that holds the parameter values to be used during the invocation of the method. This member MAY be omitted. If present, parameters for the rpc call MUST be provided as a Structured value. Either by-position through an Array or by-name through an Object. by-position: params MUST be an Array, containing the values in the Server expected order. by-name: params MUST be an Object, with member names that match the Server expected parameter names. The absence of expected names MAY result in an error being generated. The names MUST match exactly, including case, to the method's expected parameters.

Methods

__construct()  : mixed
__toString()  : string
isRequest()  : bool
A message is considered a Request if it has an ID and a method.
parse()  : Message
Returns the appropriate Message subclass

Properties

$id

An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be NULL and Numbers SHOULD NOT contain fractional parts.

public int|string $id

$jsonrpc

A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0".

public string $jsonrpc = '2.0'

$method

A String containing the name of the method to be invoked. Method names that begin with the word rpc followed by a period character (U+002E or ASCII 46) are reserved for rpc-internal methods and extensions and MUST NOT be used for anything else.

public string $method

$params

A Structured value that holds the parameter values to be used during the invocation of the method. This member MAY be omitted. If present, parameters for the rpc call MUST be provided as a Structured value. Either by-position through an Array or by-name through an Object. by-position: params MUST be an Array, containing the values in the Server expected order. by-name: params MUST be an Object, with member names that match the Server expected parameter names. The absence of expected names MAY result in an error being generated. The names MUST match exactly, including case, to the method's expected parameters.

public object|array<string|int, mixed>|null $params

Methods

__construct()

public __construct(string|int $id, string $method[, object|array<string|int, mixed> $params = null ]) : mixed
Parameters
$id : string|int
$method : string
$params : object|array<string|int, mixed> = null

__toString()

public __toString() : string
Return values
string

isRequest()

A message is considered a Request if it has an ID and a method.

public static isRequest(object $msg) : bool
Parameters
$msg : object

A decoded message body

Return values
bool

parse()

Returns the appropriate Message subclass

public static parse(string $msg) : Message
Parameters
$msg : string
Return values
Message

        
On this page

Search results