請問 workerman TcpConnection 類中 onWebSocketConnect回調(diào)方法 是不是文檔沒有寫啊
在csdn上找到的這個(gè)方法 實(shí)現(xiàn)鏈接傳參的功能也實(shí)現(xiàn)了 就是沒有找到官方文檔
public function onConnect(TcpConnection $connection)
{
$this->connections[$connection->id] = $connection;
$connection->lastMessageTime = time();
$connection->uniqueId = $connection->getLocalIp() . '-' . $connection->getLocalPort() . '-' . $connection->worker->id . '-' . $connection->id;
$connection->onWebSocketConnect = function (TcpConnection $connection,$http_header) {
if (!isset($_SERVER['HTTP_ORIGIN']) ) {
throw new Exception('鏈接unique_id=' . $connection->uniqueId . ',鏈接參數(shù) HTTP_ORIGIN 錯(cuò)誤', 1025);
}
if (!isset($_GET['token']) || !$_GET['token']) {
throw new Exception('鏈接unique_id=' . $connection->uniqueId . ',鏈接參數(shù)錯(cuò)誤,不能為空', 1026);
}
$token = $_GET['token'];
var_dump('鏈接 '. $connection->uniqueId);
$this->handle->login($connection, $token, $this->response->connection($connection));
};
}
手冊websocket協(xié)議里有 http://www.wtbis.cn/doc/workerman/appendices/about-websocket.html