[fix] ZoneTcpClient

This commit is contained in:
Lkeme 2020-04-20 20:42:07 +08:00
parent d56cd94d1e
commit 5b776d5436
2 changed files with 8 additions and 3 deletions

View File

@ -14,6 +14,7 @@
- 修复风暴回显过滤 - 修复风暴回显过滤
- 修复一处舰长处理 - 修复一处舰长处理
- 修复中奖记录通知 - 修复中奖记录通知
- 修复分区监控异常
- -
## v0.3.0.200410 alpha (2020-04-10) ## v0.3.0.200410 alpha (2020-04-10)

View File

@ -410,11 +410,11 @@ class ZoneTcpClient
return self::packMsg(json_encode([ return self::packMsg(json_encode([
"uid" => 0, "uid" => 0,
"roomid" => intval($room_id), "roomid" => intval($room_id),
"protover" => 2,
"platform" => "web", "platform" => "web",
"clientver" => "1.10.6", "clientver" => "1.10.6",
"protover" => 2,
"type" => 2, "type" => 2,
"key" => Live::getDanMuToken($room_id) // "key" => Live::getDanMuToken($room_id)
]), 0x0007); ]), 0x0007);
} }
@ -476,6 +476,10 @@ class ZoneTcpClient
$ret = 0; $ret = 0;
$socket = self::$client->getResource(); $socket = self::$client->getResource();
while ($length) { while ($length) {
if ($length < 1 || $length > 65535) {
Log::warning("Socket error: [{$ret}] [{$length}]" . PHP_EOL);
throw new Exception("Connection failure");
}
$cnt = 0; $cnt = 0;
$r = array($socket); $r = array($socket);
$w = NULL; $w = NULL;
@ -489,7 +493,7 @@ class ZoneTcpClient
} }
$ret = socket_recv($socket, $buffer, $length, 0); $ret = socket_recv($socket, $buffer, $length, 0);
if ($ret < 1) { if ($ret < 1) {
print_r("Socket error: [{$ret}] [{$length}]" . PHP_EOL); Log::warning("Socket error: [{$ret}] [{$length}]" . PHP_EOL);
throw new Exception("Connection failure"); throw new Exception("Connection failure");
} }
$data .= $buffer; $data .= $buffer;