Browse Source

[2768] Implement the rpcCall method

Michal 'vorner' Vaner 12 years ago
parent
commit
845ffd35d1
1 changed files with 16 additions and 4 deletions
  1. 16 4
      src/lib/config/ccsession.cc

+ 16 - 4
src/lib/config/ccsession.cc

@@ -858,11 +858,23 @@ ModuleCCSession::cancelAsyncRecv(const AsyncRecvRequestID& id) {
 }
 
 ConstElementPtr
-ModuleCCSession::rpcCall(const std::string &, const std::string &,
-                         const std::string &, const std::string &,
-                         const ConstElementPtr &)
+ModuleCCSession::rpcCall(const std::string &command, const std::string &group,
+                         const std::string &instance, const std::string &to,
+                         const ConstElementPtr &params)
 {
-    return (ConstElementPtr());
+    const ConstElementPtr &command_el(createCommand(command, params));
+    const int seq = session_.group_sendmsg(command_el, group, instance, to);
+    ConstElementPtr env, answer;
+    session_.group_recvmsg(env, answer, false, seq);
+    int rcode;
+    const ConstElementPtr &result(parseAnswer(rcode, answer));
+    if (rcode == isc::cc::CC_REPLY_NO_RECPT) {
+        isc_throw(RPCRecipientMissing, result);
+    } else if (rcode != isc::cc::CC_REPLY_SUCCESS) {
+        isc_throw_1(RPCError, result, rcode);
+    } else {
+        return (result);
+    }
 }
 
 }