请问 workerman TcpConnection 类中 onWebSocketConnect回调方法 是不是文档没有写啊
在csdn上找到的这个方法 实现链接传参的功能也实现了 就是没有找到官方文档
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 . ',链接参数 HTTP_ORIGIN 错误', 1025);
}
if (!isset($_GET['token']) || !$_GET['token']) {
throw new Exception('链接unique_id=' . $connection->uniqueId . ',链接参数错误,不能为空', 1026);
}
$token = $_GET['token'];
var_dump('链接 '. $connection->uniqueId);
$this->handle->login($connection, $token, $this->response->connection($connection));
};
}
手册websocket协议里有 https://www.workerman.net/doc/workerman/appendices/about-websocket.html
好的 谢谢
他这手册写的不行啊