国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

Gateway類的onClose回調(diào)偶發(fā)無法獲取uid屬性

IT男

問題描述

在webman項目中使用了Gateway-worker,在process.php的gateway.constructor中添加了onClose回調(diào),在回調(diào)里面獲取uid屬性,出現(xiàn)偶爾無法獲取該屬性的報錯,然后整個項目程序卡住,接口全部處于pending

程序代碼

config\plugin\webman\gateway-worker\process.php部分代碼如下:

'gateway' => [
    'handler'     => Gateway::class,
    'listen'      => 'websocket://0.0.0.0:7777',
    'count'       => 2,
    'reloadable'  => false,
    'constructor' => ['config' => [
        'lanIp'           => '127.0.0.1',
        'startPort'       => 2300,
        'pingInterval'    => 25,
        'pingData'        => '{"type":"ping"}',
        'registerAddress' => '127.0.0.1:1212',
        'onConnect'       => function($gateway){
            // print_r($gateway);
        },
        'onClose' => function ($gateway){
            // 發(fā)布事件
            Event::dispatch('gateway.close', $gateway);
        }
        ]]
    ]

config\event.php部分代碼如下

'gateway.close' => [
    [app\controller\UserController::class, 'wsClose'],
    [app\controller\AdminController::class, 'wsClose'],
]

app\controller\UserController.php部分代碼如下:

public function wsClose($gateway){
    print_r($gateway->uid);
}

app\controller\AdminController.php部分代碼如下:

public function wsClose($gateway){
    print_r($gateway->uid);
}

報錯信息

Undefined property: Workerman\Connection\TcpConnection::$uidErrorException: Undefined property: Workerman\Connection\TcpConnection::$uid

操作系統(tǒng)及workerman/webman等框架組件具體版本

window10系統(tǒng)
"workerman/webman-framework": "^2.1",
"webman/gateway-worker": "^1.0",

110 1 0
1個回答

你是怎么保證TcpConnection::$uid一定就會存在的?

  • IT男 7天前

    已經(jīng)解決了,多處調(diào)用就一定會出現(xiàn)這個問題,單次調(diào)用就不會

??