composer create-project workerman/webman test
cd test
composer require webman/gateway-worker
把默认的registerAddress修改为2236
return [
'gateway' => [
'handler' => Gateway::class,
'listen' => 'websocket://0.0.0.0:7272',
'count' => 2,
'reloadable' => false,
'constructor' => ['config' => [
'lanIp' => '127.0.0.1',
'startPort' => 2300,
'pingInterval' => 25,
'pingData' => '{"type":"ping"}',
'registerAddress' => '127.0.0.1:2236',
'onConnect' => function(){},
]]
],
'worker' => [
'handler' => BusinessWorker::class,
'count' => cpu_count()*2,
'constructor' => ['config' => [
'eventHandler' => plugin\webman\gateway\Events::class,
'name' => 'ChatBusinessWorker',
'registerAddress' => '127.0.0.1:2236',
]]
],
'register' => [
'handler' => Register::class,
'listen' => 'text://127.0.0.1:2236',
'count' => 1, // Must be 1
'reloadable' => false,
'constructor' => []
],
];
public static function onWorkerStart($worker)
{
var_dump(Gateway::$registerAddress);
}
打印出来端口还是1236,并不是2236 但是我看程序还是正常.
配置里设置的是$businessWorker->registerAddress的值,不影响 Lib\Gateway::$registerAddress的值。
businessWorker进程里设置 Lib\Gateway::$registerAddress 没有意义,内部不会使用这个Lib\Gateway::$registerAddress的值
哦哦,明白了,谢谢