Class that writes the JSON-RPC response byte string.
More...
#include "nn/nlib/msgpack/jsonrpc/JsonRpcResponse.h"
Class that writes the JSON-RPC response byte string.
- Description
- This class is used on the server side of JSON-RPC.
The send process after converting to a byte string must be written by the user.
Not required when using JsonRpcServerExec
for server processing. It is used within JsonRpcServerExec
.
Definition at line 100 of file JsonRpcResponse.h.
◆ JsonRpcResponseWriter()
nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::JsonRpcResponseWriter |
( |
bool |
msgpack | ) |
|
|
inlineexplicitnoexcept |
Creates a msgpack
byte string when true
is specified as the argument.
- Parameters
-
[in] | msgpack | Set to true if creating a msgpack byte string. |
Definition at line 129 of file JsonRpcResponse.h.
◆ BeginWriteResponse()
nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::BeginWriteResponse |
( |
uint32_t |
n | ) |
|
|
noexcept |
Called once before writing the JSON-RPC response.
- Parameters
-
[in] | n | Number of responses (n >= 2 for responses to a batch request). |
- Return values
-
0 | Success. |
ENOMEM | memory allocation failed. |
◆ EndWriteResponse() [1/2]
nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::EndWriteResponse |
( |
UniquePtrType * |
ptr, |
|
|
size_t * |
n |
|
) |
| |
|
noexcept |
Finishes writing the JSON-RPC response.
- Parameters
-
[out] | ptr | Pointer to the byte string. |
[out] | n | Pointer where the byte count of the data is written to. |
- Return values
-
0 | Success. |
EINVAL | ptr or n is NULL . |
ERANGE | The response count does not match the number specified in BeginWriteRequest . |
ENOMEM | memory allocation failed. |
- Description
- When successful, n byte data is set to the ptr parameter. The server side process is completed by sending this data to the client.
◆ EndWriteResponse() [2/2]
nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::EndWriteResponse |
( |
| ) |
|
|
noexcept |
Completes writing a JSON-RPC response and returns a tupple of the error value, byte string, and the byte string size.
- Return values
-
0,buf,bufsize | Success. |
ERANGE,nullptr,0 | The response count does not match the number specified in BeginWriteRequest() . |
ENOMEM,nullptr,0 | Indicates memory allocation failed. |
- Description
- The server side process is completed by sending the returned byte string to the client. Only if the error value is 0, the byte string and the byte string size in the tupple are valid.
◆ WriteResponse()
nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::WriteResponse |
( |
JsonRpcResponse * |
result | ) |
|
|
noexcept |
Writes the JSON-RPC response.
- Parameters
-
- Return values
-
0 | Success. |
EINVAL | Indicates that result is NULL . |
ERANGE | The request count is larger than the number specified in BeginWriteRequest . |
ENOMEM | memory allocation failed. |
An | error occurred. Another JSON/msgpack write operation failed. |
- Description
- In some cases the object that result points to is altered.
The documentation for this class was generated from the following files: