我想在GateWay的worker類里實(shí)現(xiàn)捕獲buffer溢出時(shí),保存異常標(biāo)識(shí)到session里。
但是報(bào)錯(cuò)了Undefined variable: _SESSION
$gateway->pingData = '';
// 采用二進(jìn)制傳輸數(shù)據(jù)
$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進(jìn)程內(nèi)可以操作 $_SESSION,但是gateway進(jìn)程不能操作 $_SESSION, 且該進(jìn)程內(nèi)客戶端會(huì)話保存在 $connection->session;