Exemplo n.º 1
0
 /**
  * Exception handler
  *
  * @param Exception $e
  */
 public function exceptionHandler($e)
 {
     $response = new Response();
     $response->setException(get_class($e));
     $response->setExceptionMessage($e->getMessage());
     $response->setHasException(true);
     $this->transport->reply($response);
 }
Exemplo n.º 2
0
 /**
  * @param Invocation $invocation
  * @return Response
  * @throws InitiallyRpcException
  */
 public function invoke(Invocation $invocation)
 {
     $methodName = $invocation->getMethodName();
     $arguments = $invocation->getArguments();
     if (!method_exists($this->target, $methodName)) {
         throw new InitiallyRpcException("method not exists");
     } else {
         if (empty($arguments)) {
             $result = call_user_func(array($this->target, $methodName));
         } else {
             $result = call_user_func_array(array($this->target, $methodName), $arguments);
         }
     }
     $response = new Response();
     $response->setResult($result);
     return $response;
 }