| 16 | BatchCall::BatchCall() : id(1) {} |
| 17 | |
| 18 | int BatchCall::addCall(const string &methodname, const Json::Value ¶ms, bool isNotification) { |
| 19 | Json::Value call; |
| 20 | call[RpcProtocolClient::KEY_PROTOCOL_VERSION] = "2.0"; |
| 21 | call[RpcProtocolClient::KEY_PROCEDURE_NAME] = methodname; |
| 22 | |
| 23 | if (params.isNull() || !params.empty()) |
| 24 | call[RpcProtocolClient::KEY_PARAMETER] = params; |
| 25 | |
| 26 | if (!isNotification) { |
| 27 | call[RpcProtocolClient::KEY_ID] = this->id++; |
| 28 | } |
| 29 | result.append(call); |
| 30 | |
| 31 | if (isNotification) |
| 32 | return -1; |
| 33 | return call[RpcProtocolClient::KEY_ID].asInt(); |
| 34 | } |
| 35 | |
| 36 | string BatchCall::toString(bool fast) const { |
| 37 | string result; |