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

Method CallProcedures

src/jsonrpccpp/client/client.cpp:30–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void Client::CallProcedures(const BatchCall &calls, BatchResponse &result) {
31 std::string request, response;
32 request = calls.toString();
33 connector.SendRPCMessage(request, response);
34 Json::Value tmpresult;
35
36 try {
37 istringstream(response) >> tmpresult;
38 if(!tmpresult.isArray()) {
39 throw JsonRpcException(Errors::ERROR_CLIENT_INVALID_RESPONSE, "Array expected.");
40 }
41 } catch (const Json::Exception &e) {
42 throw JsonRpcException(Errors::ERROR_RPC_JSON_PARSE_ERROR, Errors::GetErrorMessage(Errors::ERROR_RPC_JSON_PARSE_ERROR), response);
43 }
44
45 for (unsigned int i = 0; i < tmpresult.size(); i++) {
46 if (tmpresult[i].isObject()) {
47 Json::Value singleResult;
48 try {
49 Json::Value id = this->protocol->HandleResponse(tmpresult[i], singleResult);
50 result.addResponse(id, singleResult, false);
51 } catch (JsonRpcException &ex) {
52 Json::Value id = -1;
53 if (tmpresult[i].isMember("id"))
54 id = tmpresult[i]["id"];
55 result.addResponse(id, tmpresult[i]["error"], true);
56 }
57 } else
58 throw JsonRpcException(Errors::ERROR_CLIENT_INVALID_RESPONSE, "Object in Array expected.");
59 }
60}
61
62BatchResponse Client::CallProcedures(const BatchCall &calls) {
63 BatchResponse result;

Callers 1

test_client.cppFile · 0.80

Calls 6

sizeMethod · 0.80
HandleResponseMethod · 0.80
addResponseMethod · 0.80
JsonRpcExceptionClass · 0.50
toStringMethod · 0.45
SendRPCMessageMethod · 0.45

Tested by

no test coverage detected