walkor

Results 250 comments of walkor

GatewayWorker里不支持设置`GatewayWorker\Lib\Gateway::$registerAddress`

将gatewayworker/src/Lib/Context.php 里 addressToClientId 和 clientIdToAddress 替换成如下代码。这样就加了一个时间戳前缀,避免重启后client_id冲突 ```php /** * 通讯地址到 client_id 的转换 * * @param int $local_ip * @param int $local_port * @param int $connection_id * @return string */ public...

```php return bin2hex(pack('NNnN', time(), $local_ip, $local_port, $connection_id)); ``` 改成 ```php if (!$this->time) { $this->time = time(); } return bin2hex(pack('NNnN', $this->time, $local_ip, $local_port, $connection_id)); ``` 试下。 时间戳应该是个定值,只有进程重启了才能变化。

异常一看起来是 手动调用了 GatewayProtocol::decode()方法,传输的数据长度不够,框架流程应该是先调用input判断长度是否足够,足够才会调用decode,从报错看是直接调用了decode。看下你的代码是否有手动调用它,或者改了gatewayWorker源码。 异常二有可能和异常一有关,先定位异常一。 /xxx/vendor/workerman/gateway-worker/src/Protocols/GatewayProtocol.php:198 unpack返回失败时,记录下日志。 利用Excpetion把$buffer和调用栈记录下来,看下哪里调用的decode,记录方法类似 ```php file_put_contents('/tmp/gateway.log', "buffer:$buffer" . (new Excpetion('GatewayProtocol')). "\n"), FILE_APPEND); ```

这个类不维护了,因为有些老项目还在用所以没后删除。如果你还想用这个Db类可以发个PR我这边合并。

There is no such api and business worker not hold any client connections.

You can refer to `Gateway::getAllClientIdCount` to implement the interface you need.

Please post your start_gateway.php content.

Create start_gateway2.php which like this. ```php

Just call Gateway::sendToClient($clientId1,$message, $raw);