nlib
|
JSON-RPC 2.0 を実装しています。 [詳解]
クラス | |
class | JsonRpcClient |
JSON-RPCのクライアント側の管理を行うクラスです。 [詳解] | |
class | JsonRpcRequest |
JSON-RPCのリクエストを表すクラスです。 [詳解] | |
class | JsonRpcRequestReader |
JSON-RPCリクエストを読み込むためのクラスです。 [詳解] | |
class | JsonRpcRequestWriter |
JSON-RPCのリクエストをシリアライズしてメモリに書きこむためのクラスです。 [詳解] | |
class | JsonRpcResponse |
JSON-RPCのレスポンスを表すクラスです。 [詳解] | |
class | JsonRpcResponseReader |
JSON-RPCのレスポンスのバイト列を読み込むためのクラスです。 [詳解] | |
class | JsonRpcResponseWriter |
JSON-RPCのレスポンスのバイト列を書きこむためのクラスです。 [詳解] | |
型定義 | |
typedef uint32_t | reqid_t |
JSON-RPCのリクエストに付与されるidの型です。 [詳解] | |
typedef JsonRpcServerFuncCallError(* | JsonRpcServerFunc) (MpObject ¶m, JsonRpcResponse &response) |
JSON-RPCのメソッドハンドラです。 [詳解] | |
列挙型 | |
enum | JsonRpcServerFuncCallError { JSONSERVER_OK = 0, JSONSERVER_PARSE_ERROR = -32700, JSONSERVER_INVALID_REQUEST = -32600, JSONSERVER_METHOD_NOT_FOUND = -32601, JSONSERVER_INVALID_PARAMS = -32602, JSONSERVER_INTERNAL_ERROR = -32603 } |
サーバー側のJSON-RPCメソッドハンドラの戻り値です。 [詳解] | |
関数 | |
errno_t | AddJsonRpcServerMethod (const char *method, JsonRpcServerFunc func) |
JSON-RPCのメソッドハンドラを登録します。 [詳解] | |
JsonRpcServerFunc | GetJsonRpcServerMethod (const char *method) |
メソッド名を指定して登録されているJSON-RPCのメソッドハンドラを取得します。 [詳解] | |
void | ClearJsonRpcServerMethodTable () |
登録されているJSON-RPCのメソッドハンドラを全て削除します。 | |
size_t | JsonRpcServerExec (const void *p, size_t n, ReallocOutputStream::UniquePtrType *ptr) |
JSON-RPCリクエストを処理してJSON-RPCレスポンスのバイト列を作成します。 [詳解] | |
JSON-RPC 2.0 を実装しています。
nlib
ではクライアント側もサーバー側も実装することができます。 nlib
はJSON-RPC 2.0を実装しています(JSON-RPC 1.0については実装されていません)。nlib
ではJSONの代わりにmsgpack
を利用して通信することも可能です。nlib
のJSON-RPCはJSONの代わりにより効率のよいmsgpack
を利用して通信することが可能です。 JsonRpcServerFuncCallError(* nn::nlib::msgpack::jsonrpc::JsonRpcServerFunc)(MpObject ¶m, JsonRpcResponse &response) |
JSON-RPCのメソッドハンドラです。
[in] | param | JSON-RPC呼び出し関数のパラメータ |
[in,out] | response |
JsonRpcServerFuncCallError
に定義されたエラー以外のエラーをレスポンスとして返したい場合は、 JsonRpcResponse::SetError() を呼び出しエラーを設定して JSONSERVER_OK を返します。 JsonRpcServerExec.h の 32 行目に定義があります。
uint32_t nn::nlib::msgpack::jsonrpc::reqid_t |
JSON-RPCのリクエストに付与されるidの型です。
nlib
のJSON-RPCでは正の整数のみが可能です。 JsonRpcClient::GenerateId()
を用いて生成します。 JsonRpcClient.h の 19 行目に定義があります。
サーバー側のJSON-RPCメソッドハンドラの戻り値です。
JSONSERVER_OK
以外を設定した場合、JSON-RPC 2.0で定義されているエラーをレスポンスオブジェクトを設定することなくレスポンスに設定することができます。 JsonRpcServerExec.h の 23 行目に定義があります。
nn::nlib::msgpack::jsonrpc::AddJsonRpcServerMethod | ( | const char * | method, |
JsonRpcServerFunc | func | ||
) |
JSON-RPCのメソッドハンドラを登録します。
[in] | method | メソッド名 |
[in] | func | JSON-RPCのメソッドハンドラ |
0 | 成功しました。 |
EINVAL | method 又はfunc がNULL の場合 |
ENOMEM | メモリの確保に失敗した場合 |
nn::nlib::msgpack::jsonrpc::GetJsonRpcServerMethod | ( | const char * | method | ) |
メソッド名を指定して登録されているJSON-RPCのメソッドハンドラを取得します。
[in] | method | メソッド名 |
nn::nlib::msgpack::jsonrpc::JsonRpcServerExec | ( | const void * | p, |
size_t | n, | ||
ReallocOutputStream::UniquePtrType * | ptr | ||
) |
JSON-RPCリクエストを処理してJSON-RPCレスポンスのバイト列を作成します。
[in] | p | JSON-RPCリクエストのバイト列へのポインタ |
[in] | n | JSON-RPCリクエストのバイト列のサイズ |
[out] | ptr | JSON-RPCレスポンスのバイト列が格納されるポインタ |
msgpack
だった場合はmsgpack
でレスポンスを返します。 © 2012-2016 Nintendo Co., Ltd. All rights reserved.