我想在GateWay的worker类里实现捕获buffer溢出时,保存异常标识到session里。
但是报错了Undefined variable: _SESSION
$gateway->pingData = '';
// 采用二进制传输数据
$gateway->onConnect = function($connection)
{
$connection->websocketType = Websocket::BINARY_TYPE_ARRAYBUFFER;
};
$gateway->onBufferFull = function($connection)
{
global $GlobalClient;
echo 'client_id---'.$_SESSION['client_id'].' is buffer full';
$GlobalClient->add($_SESSION['client_id'].'_cache',1);
$GlobalClient->add($_SESSION['client_id'].'_cache_data',array());
};
不可以
business进程内可以操作 $_SESSION,但是gateway进程不能操作 $_SESSION, 且该进程内客户端会话保存在 $connection->session;
多谢,我是想在这个里面标记流推送丢失然后下次补传的逻辑。