MCPcopy Create free account
hub / github.com/cinemast/libjson-rpc-cpp / HandleJsonRequest

Method HandleJsonRequest

src/jsonrpccpp/server/rpcprotocolserverv1.cpp:18–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16RpcProtocolServerV1::RpcProtocolServerV1(IProcedureInvokationHandler &handler) : AbstractProtocolHandler(handler) {}
17
18void RpcProtocolServerV1::HandleJsonRequest(const Json::Value &req, Json::Value &response) {
19 if (req.isObject()) {
20 int error = this->ValidateRequest(req);
21 if (error == 0) {
22 try {
23 this->ProcessRequest(req, response);
24 } catch (const JsonRpcException &exc) {
25 this->WrapException(req, exc, response);
26 }
27 } else {
28 this->WrapError(req, error, Errors::GetErrorMessage(error), response);
29 }
30 } else {
31 this->WrapError(Json::nullValue, Errors::ERROR_RPC_INVALID_REQUEST, Errors::GetErrorMessage(Errors::ERROR_RPC_INVALID_REQUEST), response);
32 }
33}
34
35bool RpcProtocolServerV1::ValidateRequestFields(const Json::Value &request) {
36 if (!(request.isMember(KEY_REQUEST_METHODNAME) && request[KEY_REQUEST_METHODNAME].isString()))

Callers 2

HandleRequestMethod · 0.45
HandleRequestMethod · 0.45

Calls 4

WrapExceptionMethod · 0.95
WrapErrorMethod · 0.95
ValidateRequestMethod · 0.80
ProcessRequestMethod · 0.45

Tested by

no test coverage detected