Kraken\Channel\Model\Socket\Socket::sendMessage PHP Метод

sendMessage() приватный Метод

private sendMessage ( string $id, string $type, string | string[] $message = null, integer $flags = Channel::MODE_STANDARD ) : boolean
$id string
$type string
$message string | string[]
$flags integer
Результат boolean
    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;
    }