예제 #1
0
파일: Buffer.php 프로젝트: khelle/surume
 /**
  *
  */
 public function send()
 {
     foreach ($this->messageBuffer as $message) {
         $this->socket->send($message);
     }
     $this->messageBuffer = [];
     $this->messageBufferSize = 0;
 }
예제 #2
0
파일: ZmqModel.php 프로젝트: khelle/surume
 /**
  * @param string $id
  * @param string $type
  * @param mixed $message
  * @param int $flags
  * @return bool
  */
 private function sendMessage($id, $type, $message = null, $flags = self::MODE_STANDARD)
 {
     if (($frame = $this->getFrame($id, $type, $message)) === null) {
         return false;
     }
     $isConnected = $this->isConnected();
     if (!$isConnected) {
         if ($this->flags['enableBuffering'] === true && ($flags & self::MODE_BUFFER_OFFLINE) === self::MODE_BUFFER_OFFLINE) {
             return $this->buffer->add($frame);
         }
     } else {
         if ($type === self::COMMAND_HEARTBEAT) {
             if ($this->socket->closed === false && $this->socket->send($frame)) {
                 $this->connectionPool->registerHeartbeat($id);
                 return true;
             }
         } else {
             if ($this->flags['enableHeartbeat'] === false || $this->flags['enableBuffering'] === true && ($flags & self::MODE_BUFFER_ONLINE) === self::MODE_BUFFER_ONLINE || $this->connectionPool->validateConnection($id) === true) {
                 $this->socket->send($frame);
                 $this->connectionPool->registerHeartbeat($id);
                 return true;
             }
         }
     }
     return false;
 }