nlib
nn::nlib::msgpack::jsonrpc::JsonRpcRequest Class Referencefinal

Class for representing a JSON-RPC request. More...

#include "nn/nlib/msgpack/jsonrpc/JsonRpcRequest.h"

Public Member Functions

 JsonRpcRequest ()
 Instantiates the object with default parameters (default constructor).
 
reqid_t GetId () const
 Get the id of the request. If 0, the request is a notification. More...
 
const char * GetMethod () const
 Gets the method name of the request. More...
 
const MpObjectGetParams () const
 Gets the parameter of the request. More...
 
MpObjectGetParams ()
 Gets the parameter of the request. More...
 
void SetId (reqid_t id)
 Sets the request ID. More...
 
bool SetMethod (const char *method)
 Sets the ID for the request. More...
 
void MoveParamsFrom (MpObject &params)
 Sets the JSON-RPC parameters. More...
 

Detailed Description

Class for representing a JSON-RPC request.

Description
The RPC call of a JSON-RPC is done by sending a request in JSON format to the server. A JSON-RPC request is a JSON associative array containing the following four keys.
jsonrpc:
The string 2.0 becomes the value.
method:
The function name called remotely is set as a string for this value.
params:
Parameter passed to the function called remotely.
id:
Specifies the 32-bit positive integer generated by JsonRpcClient::GenerateId. The server associates the response to the request by assigning the same id parameter.
If id is not contained in the request, that request is a notification, and the server does not respond to it.

Definition at line 32 of file JsonRpcRequest.h.

Member Function Documentation

nn::nlib::msgpack::jsonrpc::JsonRpcRequest::GetId ( ) const
inline

Get the id of the request. If 0, the request is a notification.

Returns
ID of the JSON-RPC request.

Definition at line 37 of file JsonRpcRequest.h.

nn::nlib::msgpack::jsonrpc::JsonRpcRequest::GetMethod ( ) const
inline

Gets the method name of the request.

Returns
Method name.

Definition at line 38 of file JsonRpcRequest.h.

nn::nlib::msgpack::jsonrpc::JsonRpcRequest::GetParams ( ) const
inline

Gets the parameter of the request.

Returns
Parameter.

Definition at line 39 of file JsonRpcRequest.h.

nn::nlib::msgpack::jsonrpc::JsonRpcRequest::GetParams ( )
inline

Gets the parameter of the request.

Returns
Parameter.

Definition at line 40 of file JsonRpcRequest.h.

nn::nlib::msgpack::jsonrpc::JsonRpcRequest::MoveParamsFrom ( MpObject params)
inline

Sets the JSON-RPC parameters.

Parameters
[in,out]paramsJSON-RPC parameters.
Description
The content of params is moved to within JsonRpcRequest, instead of copying it when setting the parameters to prevent the copying of MpObject.

Definition at line 44 of file JsonRpcRequest.h.

nn::nlib::msgpack::jsonrpc::JsonRpcRequest::SetId ( reqid_t  id)
inline

Sets the request ID.

Parameters
[in]idRequest ID.
Description
Sets the id generated by JsonRpcClient::GenerateId. The id must be unique to each request.

Definition at line 42 of file JsonRpcRequest.h.

nn::nlib::msgpack::jsonrpc::JsonRpcRequest::SetMethod ( const char *  method)

Sets the ID for the request.

Parameters
[in]methodMethod name.
Returns
Returns true when successful.
Description
The method name string is copied. Returns false when dynamic memory allocation fails.

The documentation for this class was generated from the following files: