Пример #1
0
 /**
  * Send a request to the ClientHandler.
  *
  * @param string  $manager
  * @param Request $request
  * @param string  $cache
  *
  * @return ExecuteResponse
  * @throws TimeoutException
  * @throws InvalidResponseException
  */
 protected function sendExecuteRequest($manager, Request $request, $cache = null)
 {
     $serialized = $this->serializeParams($request->getParams());
     $msg = new ExecuteRequest($cache, $request->getFunction(), $serialized);
     $socket = $this->getSocket($manager);
     $stream = $socket->getStream();
     $stream->send($msg);
     try {
         $response = $stream->read(new TimeoutTimer($this->delay));
     } catch (TimeoutException $ex) {
         $this->invalidateSocket($manager);
         throw $ex;
     }
     if (!$response instanceof ExecuteResponse) {
         $msg = $manager . ': Invalid response ' . get_class($response) . '.';
         $this->getLogger()->notice($msg);
         throw new InvalidResponseException($msg);
     }
     if ('' != $response->getResult()) {
         $this->handleFetchResponse($response, $request);
     }
     return $response;
 }