| 28 | } |
| 29 | |
| 30 | void 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 | |
| 62 | BatchResponse Client::CallProcedures(const BatchCall &calls) { |
| 63 | BatchResponse result; |
no test coverage detected