Пример #1
0
 /**
  * Send reply to rpc client
  *
  * @param Response $response
  * @param Envelope $envelope
  */
 protected function sendReply(Response $response, Envelope $envelope)
 {
     $attributes = ['content_type' => 'application/json', 'content_encoding' => 'UTF-8', 'delivery_mode' => 2, 'correlation_id' => $envelope->getCorrelationId(), 'app_id' => $this->appId, 'headers' => ['jsonrpc' => JsonRpcResponse::JSONRPC_VERSION]];
     if ($response->isError()) {
         $payload = ['error' => ['code' => $response->error()->code(), 'message' => $response->error()->message()], 'data' => $response->data()];
     } else {
         $payload = ['result' => $response->result()];
     }
     $this->exchange->publish(json_encode($payload), $envelope->getReplyTo(), Constants::AMQP_NOPARAM, $attributes);
 }
 /**
  * @param Response $response
  */
 public function addResponse(Response $response)
 {
     $this->responses[$response->id()] = $response;
 }