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 () noexcept
 Instantiates the object with default parameters (default constructor).
 
reqid_t GetId () const noexcept
 Get the id of the request. If 0, the request is a notification. More...
 
const char * GetMethod () const noexcept
 Gets the method name of the request. More...
 
const MpObjectGetParams () const noexcept
 Gets the parameter of the request. More...
 
MpObjectGetParams () noexcept
 Gets the parameter of the request. More...
 
void SetId (reqid_t id) noexcept
 Sets the request ID. More...
 
bool SetMethod (const char *method) noexcept
 Sets the ID for the request. More...
 
void MoveParamsFrom (MpObject &params) noexcept
 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 44 of file JsonRpcRequest.h.

Member Function Documentation

◆ GetId()

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

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

Returns
ID of the JSON-RPC request.

Definition at line 50 of file JsonRpcRequest.h.

◆ GetMethod()

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

Gets the method name of the request.

Returns
Method name.

Definition at line 51 of file JsonRpcRequest.h.

◆ GetParams() [1/2]

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

Gets the parameter of the request.

Returns
Parameter.

Definition at line 52 of file JsonRpcRequest.h.

◆ GetParams() [2/2]

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

Gets the parameter of the request.

Returns
Parameter.

Definition at line 53 of file JsonRpcRequest.h.

◆ MoveParamsFrom()

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

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 57 of file JsonRpcRequest.h.

◆ SetId()

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

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 55 of file JsonRpcRequest.h.

◆ SetMethod()

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

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: