GateWay添加支持原数据Ping包

Larva

在示例包中看见GateWay已经支持ping pong的逻辑,但是只能发送相应协议打包好的数据
建议添加一个判断支持发送原生的数据用于ping发送
例如websocket有原生的ping协议,这样可以减少些流量,也能使onWebSocketPing,onWebSocketPong等方法能有效利用上

简单的修改了一下:
GatewayWorker/Gateway.php

增加 $pingRaw = false
ping()方法中调用 $connection->send($this->pingData); 改为 $connection->send($this->pingData, $this->pingRaw);

初始化gateway时设置 $gateway->pingRaw = true;

4836 1 0
1个回答

walkor

好的,可以考虑

  • 暂无评论
年代过于久远,无法发表回答
🔝