mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-13 03:16:05 +08:00
Add fast-fail on packet loss
This commit is contained in:
parent
c044c64b82
commit
f85a6cd5a7
@ -226,6 +226,10 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
|||||||
if (cache == null) {
|
if (cache == null) {
|
||||||
// 没有缓存
|
// 没有缓存
|
||||||
var length: Int = rawInput.readInt() - 4
|
var length: Int = rawInput.readInt() - 4
|
||||||
|
if (length < 0) {
|
||||||
|
// 丢包了. 后半部分包提前到达
|
||||||
|
return
|
||||||
|
}
|
||||||
if (rawInput.remaining == length.toLong()) {
|
if (rawInput.remaining == length.toLong()) {
|
||||||
// 捷径: 当包长度正好, 直接传递剩余数据.
|
// 捷径: 当包长度正好, 直接传递剩余数据.
|
||||||
cachedPacketTimeoutJob?.cancel()
|
cachedPacketTimeoutJob?.cancel()
|
||||||
|
Loading…
Reference in New Issue
Block a user