Hprose\Swoole\WebSocket\Service::wsPush PHP Метод

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

*private
public wsPush ( $server, $fd, $data )
    function wsPush($server, $fd, $data)
    {
        $dataLength = strlen($data);
        if ($dataLength <= self::MAX_PACK_LEN) {
            return $server->exist($fd) && $server->push($fd, $data, WEBSOCKET_OPCODE_BINARY, true);
        } else {
            for ($i = 0; $i < $dataLength; $i += self::MAX_PACK_LEN) {
                $chunkLength = min($dataLength - $i, self::MAX_PACK_LEN);
                $chunk = substr($data, $i, $chunkLength);
                $finish = $dataLength - $i === $chunkLength;
                if (!($server->exist($fd) && $server->push($fd, $chunk, WEBSOCKET_OPCODE_BINARY, $finish))) {
                    return false;
                }
            }
            return true;
        }
    }