webman里安装好了gatewayworker,只有一个websock实例,想在加tcp实例怎么做

longxiaowang

webman里安装好了gatewayworker,只有一个websock实例,想在加tcp实例怎么做

924 3 0
3个回答

walkor 打赏

config/plugin/webman/gateway-worker/process.php

<?php

use Webman\GatewayWorker\Gateway;
use Webman\GatewayWorker\BusinessWorker;
use Webman\GatewayWorker\Register;

return [
    'gateway' => [
        'handler'     => Gateway::class,
        'listen'      => 'websocket://0.0.0.0:7272',
        'count'       => cpu_count(),
        'reloadable'  => false,
        'constructor' => ['config' => [
            'lanIp'           => '127.0.0.1',
            'startPort'       => 2300,
            'pingInterval'    => 25,
            'pingData'        => '{"type":"ping"}',
            'registerAddress' => '127.0.0.1:1236',
            'onConnect'       => function(){},
        ]]
    ],
    'gateway-tcp' => [
        'handler'     => Gateway::class,
        'listen'      => 'tcp://0.0.0.0:7373', // 注意这里端口改成其它值
        'count'       => cpu_count(),
        'reloadable'  => false,
        'constructor' => ['config' => [
            'lanIp'           => '127.0.0.1',
            'startPort'       => 3300, // 注意这里端口改成其它值,步数大大一些,不能和2300太接近
            'pingInterval'    => 25,
            '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://0.0.0.0:1236',
        'count'       => 1, // Must be 1
        'constructor' => []
    ],
];
  • 暂无评论
longxiaowang

'worker' => [
'handler' => BusinessWorker::class,
'count' => cpu_count()*2,
'constructor' => ['config' => [
'eventHandler' => plugin\webman\gateway\Events::class,
'name' => 'ChatBusinessWorker',
'registerAddress' => '127.0.0.1:1236',
]]
],
这个是不是也要添加一个,单独用一个Events类吧?

  • walkor 2023-05-09

    如果是要部署2套单独的gateway-worker,worker 和 register都要新增

longxiaowang

我想用tcp连接硬件,websock把接收到硬件信息转发到网页。这样是不是events业务用两个分着写?

  • walkor 2023-05-09

    那就是一套系统,两个gateway端口支持多协议,worker 和 register不用新增。业务写在同一个events.php里。

  • longxiaowang 2023-05-09

    感谢技术支持,回复速度就是快!

年代过于久远,无法发表回答
×
🔝