Kraken\Channel\Model\Socket\Connection\ConnectionPool::validateConnection PHP Метод

validateConnection() публичный Метод

public validateConnection ( string $id ) : boolean
$id string
Результат boolean
    public function validateConnection($id)
    {
        if (!$this->existsConnection($id)) {
            return false;
        }
        return $this->validateIn($this->generateValidationConst(), $this->getData($id));
    }

Usage Example

Пример #1
0
 /**
  * @param string $id
  * @param string $type
  * @param string|string[] $message
  * @param int $flags
  * @return bool
  */
 private function sendMessage($id, $type, $message = null, $flags = Channel::MODE_STANDARD)
 {
     if (($frame = $this->getFrame($id, $type, $message)) === null) {
         return static::SEND_STATUS_DROPPED;
     }
     $isConnected = $this->isStarted();
     if (!$isConnected && $this->flags['enableBuffering'] === true && ($flags & Channel::MODE_BUFFER_OFFLINE) === Channel::MODE_BUFFER_OFFLINE) {
         $frame = $this->parseConnectorMessage($frame);
         $status = $this->offlineBuffer->push($id, $frame[2]);
         return $status ? static::SEND_STATUS_BUFFERED : static::SEND_STATUS_DROPPED;
     } else {
         if ($type === self::COMMAND_HEARTBEAT) {
             if ($this->writeData($id, $frame . "\r\n")) {
                 $this->connectionPool->registerHeartbeat($id);
                 return static::SEND_STATUS_SUCCEEDED;
             }
         } else {
             if ($this->flags['enableHeartbeat'] === false || $this->connectionPool->validateConnection($id) === true) {
                 $this->writeData($id, $frame . "\r\n");
                 $this->connectionPool->registerHeartbeat($id);
                 return static::SEND_STATUS_SUCCEEDED;
             } else {
                 if ($this->flags['enableBuffering'] === true && ($flags & Channel::MODE_BUFFER_ONLINE) === Channel::MODE_BUFFER_ONLINE) {
                     $frame = $this->parseConnectorMessage($frame);
                     $status = $this->onlineBuffer->push($id, $frame[2]);
                     return $status ? static::SEND_STATUS_BUFFERED : static::SEND_STATUS_DROPPED;
                 }
             }
         }
     }
     return static::SEND_STATUS_DROPPED;
 }