手冊里說:onClose回調(diào)里無法使用Gateway::getUidByClientId()接口來獲得uid,解決辦法是在Gateway::bindUid()時記錄一個$_SESSION,onClose的時候用$_SESSION來獲得uid。 ? 我在實際使用過程中曾用$GLOBALS來記錄uid,發(fā)現(xiàn)有時不能正確的獲得UID,是這兩個變量有什么區(qū)別么?網(wǎng)上也未查閱到相關資料,求大神們指點下。...
$worker->onWorkerStart = function($worker) { ? ? // 將db實例存儲在全局變量中(也可以存儲在某類的靜態(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...