Class to manage client side JSON-RPC.
More...
#include "nn/nlib/msgpack/jsonrpc/JsonRpcClient.h"
Class to manage client side JSON-RPC.
- Description
- It performs the following operations.
-
Uses
GenerateId
to generate the ID attached to the request.
-
Creates the
future
that will be valid if the response arrives.
-
Sorts the response from the server.
Definition at line 37 of file JsonRpcClient.h.
◆ NoTargetResponseHandler
Function type called when a response could not be sorted.
- Description
- Set in
SetNoTargetResponseHandler
.
Definition at line 45 of file JsonRpcClient.h.
◆ Abort()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::Abort |
( |
reqid_t |
reqid | ) |
|
Halts the reception of the response to a request.
- Parameters
-
- Return values
-
0 | Success. |
ESRCH | Invalid client. |
- Description
- The request returns a
JsonRpcResponse::kClientAbort
error code as a response and halts.
◆ CloseClient()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::CloseClient |
( |
const JsonRpcClient & |
client | ) |
|
|
static |
◆ GenerateId()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::GenerateId |
( |
| ) |
|
Creates and returns an ID to be placed in a JSON-RPC request.
- Returns
- Returns a nonzero unique ID.
◆ GetFutureForId()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::GetFutureForId |
( |
FutureType * |
future, |
|
|
reqid_t |
reqid |
|
) |
| |
Gets the future
that corresponds to the request ID.
- Parameters
-
[out] | future | Pointer to the future that becomes valid when the response corresponding to the request arrives. |
[in] | reqid | Request ID. |
- Return values
-
0 | Success. |
ESRCH | Invalid client. |
ENOMEM | Not enough memory. |
◆ OpenClient()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::OpenClient |
( |
const char * |
name | ) |
|
|
static |
Opens a client. If a client doesn't exist, it creates one.
- Parameters
-
[in] | name | Name of the client. |
- Returns
- Client object.
- Description
- In many cases , you create a
JsonRpcClient
object for each server.
- Sample code is provided below.
◆ ResolveResponse()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::ResolveResponse |
( |
const void * |
buf, |
|
|
size_t |
nbytes |
|
) |
| |
Receives the response data, and makes the corresponding future
valid.
- Parameters
-
[in] | buf | Pointer to response data. |
[in] | nbytes | The size of the response. |
- Return values
-
0 | Success. |
EINVAL | buf is NULL or nbytes is 0 . |
ESRCH | Invalid client. |
ENOMEM | Not enough memory. |
EILSEQ | Response data could not be parsed. |
- Description
- Correctly sorts the response received from the server (via a user defined communications path), and makes the corresponding
future
valid.
This function must be called from user code. In addition, the response data must be self-contained.
◆ SearchClient()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::SearchClient |
( |
const char * |
name | ) |
|
|
static |
Searches and returns the opened client.
- Parameters
-
[in] | name | Name of the client. |
- Returns
- Client object.
◆ SetNoTargetResponseHandler()
Sets a function called when a response could not be sorted.
- Parameters
-
- Return values
-
- Description
- A
future
that corresponds to a response cannot be made valid if a response is received after a timeout or Abort
call is made.
The response can be processed by calling handler in this case.
◆ swap()
nn::nlib::msgpack::jsonrpc::JsonRpcClient::swap |
( |
JsonRpcClient & |
rhs | ) |
|
|
inline |
The documentation for this class was generated from the following files: