我在webman里面安装了gatewayworker,开了一个tcp和一个websocket,如下图所示: 分别指向了A和B两个文件做处理,现在我的问题是: 如果我想在tcp的回调里onMessage里面去把信息通过websocket发出去,应该怎么办呢?或者我把websocket收到的消息通过tcp发出去,请问应该如何搞定。
暂未查找到合适的方案
直接使用双协议 https://www.workerman.net/doc/gateway-worker/multi-protocols.html
直接在下面建一个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(){}, ]] ],
这样不行,我试过了
那就不知道了 之前也是这样处理的 在event.php里面处理两个协议发来的数据
两个协议的gateway进程和worker进程的registerAddress都填同一个注册地址,这样两个协议的链接客户端就可以互相发消息了,在worker进程中可以通过端口区分消息的协议类型。
感谢帮助,但是我这里出现了一个小问题,还请再次帮忙一下,下面是吧把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
请问这种问题应该怎么做呢?
woker 的name别一样
非常感谢两位,已经测试成功,直接可以互发消息,非常感谢
直接使用双协议 https://www.workerman.net/doc/gateway-worker/multi-protocols.html
直接在下面建一个gateway_tcp 其他的一样 是不是也是可以的
这样不行,我试过了
那就不知道了 之前也是这样处理的 在event.php里面处理两个协议发来的数据
两个协议的gateway进程和worker进程的registerAddress都填同一个注册地址,这样两个协议的链接客户端就可以互相发消息了,在worker进程中可以通过端口区分消息的协议类型。
感谢帮助,但是我这里出现了一个小问题,还请再次帮忙一下,下面是吧把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
请问这种问题应该怎么做呢?
woker 的name别一样
非常感谢两位,已经测试成功,直接可以互发消息,非常感谢