gatewayworker和webman结合后的双通道通信的问题

sanye

问题描述

我在webman里面安装了gatewayworker,开了一个tcp和一个websocket,如下图所示:
截图
分别指向了A和B两个文件做处理,现在我的问题是:
如果我想在tcp的回调里onMessage里面去把信息通过websocket发出去,应该怎么办呢?或者我把websocket收到的消息通过tcp发出去,请问应该如何搞定。

为此你搜索到了哪些方案及不适用的原因

暂未查找到合适的方案

437 3 0
3个回答

Gin
  • 暂无评论
不败少龙

截图
直接在下面建一个gateway_tcp 其他的一样 是不是也是可以的

'gateway_tcp' => [
        'handler'     => Gateway::class,
        'listen'      => 'tcp://0.0.0.0:9898',
        '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(){},
        ]]
    ],
  • sanye 2023-10-09

    这样不行,我试过了

  • 不败少龙 2023-10-09

    那就不知道了 之前也是这样处理的 在event.php里面处理两个协议发来的数据

Leo

两个协议的gateway进程和worker进程的registerAddress都填同一个注册地址,这样两个协议的链接客户端就可以互相发消息了,在worker进程中可以通过端口区分消息的协议类型。

  • sanye 2023-10-10

    感谢帮助,但是我这里出现了一个小问题,还请再次帮忙一下,下面是吧把gateway和worker都填同一个地址后的返回:
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0
    Gateway: Worker->name conflict. Key:127.0.0.1:ChatBusinessWorker:0

  • sanye 2023-10-10

    请问这种问题应该怎么做呢?

  • Gin 2023-10-10

    woker 的name别一样

  • sanye 2023-10-10

    非常感谢两位,已经测试成功,直接可以互发消息,非常感谢

🔝