Swoole\Coroutine\Http\Client->upgrade

Declaration

<?php
Swoole\Coroutine\Http\Client->upgrade(string $path)

Parameters

path

The HTTP path.

Return

Description

Upgrade the HTTP request to be websocket.

Example

<?php
use Swoole\Coroutine\HTTP\Client;

Co\run(function() {
    $cli = new Co\http\Client("127.0.0.1", 9501);
    $ret = $cli->upgrade("/");
    if ($ret) {
        while(true) {
            $cli->push("hello");
            var_dump($cli->recv());
            co::sleep(0.5);
        }
    }
});