Exemplo n.º 1
0
 /**
  * @param \JsonRpc\Base\JsonRpcException $exception
  */
 protected function respondError(JsonRpcException $exception)
 {
     $response = ['jsonrpc' => self::JSONRPC_VERSION, 'error' => ['code' => $exception->getCode(), 'message' => $exception->getMessage()], 'id' => $this->_id];
     $data = $exception->getData();
     if ($data !== null) {
         $response['error']['data'] = $data;
     }
     if (ob_get_level()) {
         ob_end_clean();
     }
     $this->_transport->respond($response, $exception->getCode(), $this->headers);
 }
Exemplo n.º 2
0
 /**
  * Send notification.
  *
  * @param       $method
  * @param array $arguments
  * @param bool  $namedParameters
  *
  * @return bool|mixed
  */
 public function notify($method, array $arguments = [], $namedParameters = true)
 {
     $request = ['jsonrpc' => self::JSONRPC_VERSION, 'method' => $method, 'params' => $namedParameters ? (object) $arguments : array_values($arguments)];
     return $this->_transport->send(true, $request, $this->url, $this->headers);
 }