Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function send(OutgoingMessage $message)
 {
     $messageToSend = $message->serialize();
     $length = strlen($messageToSend);
     $this->lastActionId = $message->getActionId();
     if (@fwrite($this->socket, $messageToSend) < $length) {
         throw new ClientException('Could not send message');
     }
     $read = 0;
     while ($read <= $this->readWriteTimeout) {
         $this->process();
         $response = $this->getRelated($message);
         if ($response != false) {
             $this->lastActionId = false;
             return $response;
         }
         usleep(1000);
         // 1ms delay
         if ($this->readWriteTimeout > 0) {
             $read++;
         }
     }
     throw new ClientException('Read timeout');
 }
 /**
  * Constructor.
  *
  * @param string $what Action command
  */
 public function __construct($what)
 {
     parent::__construct();
     $this->setKey('Action', $what);
     $this->setKey('ActionID', microtime(true));
 }