$connection = $request->connection;
$connection->send(new Response(200, array('Content-Type' => 'application/octet-stream', 'Transfer-Encoding' => 'chunked'), 'hello'));
$con = new AsyncTcpConnection("tcp://www.baidu.com:80");
$con->onConnect = function ($con) {
$con->send("GET / HTTP/1.1\r\nHost: www.baidu.com\r\nConnection: keep-alive\r\n\r\n");
};
$con->onMessage = function ($con, $data) use ($connection) {
$connection->send("HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nTransfer-Encoding: chunked\r\n\r\n你好世界~");
// print_r(new Chunk('你好世界~'));
// $connection->send(new Chunk('你好世界~'));
$connection->send(new Chunk(''));
};
$con->connect();
$connection->send(new Chunk('hello'));
$connection->send(new Chunk('world'));
$connection->send(new Chunk('!'));
// $connection->send(new Chunk(''));
輸出結(jié)果 hellohelloworld!
onMessage 中send的信息都沒有輸出
使用的webman 1.5.0 代理服務(wù)器為vite的proxy