其中手册也写到: 手册中按照 var ws = new WebSocket('ws://127.0.0.1:7272/?token=kjxdvjkasfh')
需要在 onWebSocketConnect($$client_id, $data) 方法中获取 data的返回值,用来绑定 uid, 本地环境是可以获取到$data 的 但是linux 线上环境首次却获取不到 客户端new 的 token 参数
除非你这开一个进程,不然就使用gatewayworker
我也不知道为什么开了 4个 我设置的是一个的
<?php
use Webman\GatewayWorker\Gateway; use Webman\GatewayWorker\BusinessWorker; use Webman\GatewayWorker\Register;
return [ 'gateway' => [ 'handler' => Gateway::class, 'listen' => 'websocket://0.0.0.0:7273', 'count' => cpu_count(), 'reloadable' => false, 'constructor' => ['config' => [ 'lanIp' => '127.0.0.1', 'startPort' => 2300, 'pingInterval' => 25, 'pingNotResponseLimit ' => 1, 'pingData' => '{"type":"ping"}', 'registerAddress' => '127.0.0.1:1236', '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:1236', ]] ], 'register' => [ 'handler' => Register::class, 'listen' => 'text://127.0.0.1:1236', 'count' => 1, // Must be 1 'constructor' => [] ], ];
workerman 5.0 里面没有问题的,使用http/request 去解析的query 参数。
除非你这开一个进程,不然就使用gatewayworker
我也不知道为什么开了 4个 我设置的是一个的
<?php
use Webman\GatewayWorker\Gateway;
use Webman\GatewayWorker\BusinessWorker;
use Webman\GatewayWorker\Register;
return [
'gateway' => [
'handler' => Gateway::class,
'listen' => 'websocket://0.0.0.0:7273',
'count' => cpu_count(),
'reloadable' => false,
'constructor' => ['config' => [
'lanIp' => '127.0.0.1',
'startPort' => 2300,
'pingInterval' => 25,
'pingNotResponseLimit ' => 1,
'pingData' => '{"type":"ping"}',
'registerAddress' => '127.0.0.1:1236',
'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:1236',
]]
],
'register' => [
'handler' => Register::class,
'listen' => 'text://127.0.0.1:1236',
'count' => 1, // Must be 1
'constructor' => []
],
];
workerman 5.0 里面没有问题的,使用http/request 去解析的query 参数。