コード例 #1
0
ファイル: JsonProcessor.php プロジェクト: comodojo/rpcclient
 private static function composeJsonRequest(RpcRequest $request)
 {
     $return = array("jsonrpc" => "2.0", "method" => $request->getMethod(), "params" => $request->getParameters());
     $rid = $request->getId();
     if ($rid === true) {
         $id = $return["id"] = $request->getUniqueId();
     } else {
         if (is_scalar($rid)) {
             $id = $return["id"] = $rid;
         } else {
             $id = null;
         }
     }
     return array($return, $id);
 }
コード例 #2
0
ファイル: XmlProcessor.php プロジェクト: comodojo/rpcclient
 private function encodeSingleCall(RpcRequest $request)
 {
     $this->logger->notice("Performing a single XML call");
     $this->logger->debug("Data dump before encoding", $request->toArray());
     try {
         // encoding
         foreach ($request->getSpecialTypes() as $key => $value) {
             $this->encoder->setValueType($key, $value);
         }
         $encoded_request = $this->encoder->encodeCall($request->getMethod(), $request->getParameters());
     } catch (XmlrpcException $xe) {
         throw $xe;
     }
     $this->logger->debug("Data dump after encoding: " . $encoded_request);
     return $encoded_request;
 }
コード例 #3
0
 public function testMulticall()
 {
     $string = "comodojo";
     try {
         $this->rpch->addRequest(RpcRequest::create("add", array(40, 2)))->addRequest(RpcRequest::create("echo", array($string)));
         $result = $this->rpch->send();
     } catch (\Exception $e) {
         throw $e;
     }
     $this->assertSame(42, $result[0]['result']);
     $this->assertSame($string, $result[1]['result']);
 }
コード例 #4
0
 private function commonRequests($method, $parameters = array())
 {
     try {
         $request = RpcRequest::create($method, $parameters);
         $this->rpch->addRequest($request);
         $this->rpch->transport()->setTimeout(3);
         $result = $this->rpch->send();
     } catch (\Exception $e) {
         throw $e;
     }
     return $result;
 }
コード例 #5
0
ファイル: RpcRequest.php プロジェクト: comodojo/rpcclient
 public static function create($method, $parameters = array(), $id = true)
 {
     $request = new RpcRequest();
     try {
         $request->setMethod($method)->setParameters($parameters)->setId($id);
     } catch (Exception $e) {
         throw $e;
     }
     return $request;
 }