手冊(cè)里說:onClose回調(diào)里無法使用Gateway::getUidByClientId()接口來獲得uid,解決辦法是在Gateway::bindUid()時(shí)記錄一個(gè)$_SESSION,onClose的時(shí)候用$_SESSION來獲得uid。 ? 我在實(shí)際使用過程中曾用$GLOBALS來記錄uid,發(fā)現(xiàn)有時(shí)不能正確的獲得UID,是這兩個(gè)變量有什么區(qū)別么?網(wǎng)上也未查閱到相關(guān)資料,求大神們指點(diǎn)下。...
$worker->onWorkerStart = function($worker) { ? ? // 將db實(shí)例存儲(chǔ)在全局變量中(也可以存儲(chǔ)在某類的靜態(tài)成員中) ? ? global $db1; ? ? global $db2; ? ? global $db3; ? ? ... ? ? $db1 = new \Workerman\MySQL\Connection('host', 'port', 'user',...
for($i=0;$i<=count($arr)-1;$i++){ ? $uid = $arr->device_id; $command = $arr->command; $GLOBALS = Timer::add($arr->frequency, function()use($command ){ Gateway::sendToAll(st...