Commit 12c38b94 authored by Him188's avatar Him188

Fix IllegalStateException when losing packet

parent 7172ef62
...@@ -531,6 +531,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo ...@@ -531,6 +531,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
val cache = cachedPacket.value val cache = cachedPacket.value
if (cache == null) { if (cache == null) {
kotlin.runCatching {
// 没有缓存 // 没有缓存
var length: Int = rawInput.readInt() - 4 var length: Int = rawInput.readInt() - 4
if (rawInput.remaining == length.toLong()) { if (rawInput.remaining == length.toLong()) {
...@@ -560,6 +561,10 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo ...@@ -560,6 +561,10 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
cachedPacketTimeoutJob?.cancel() cachedPacketTimeoutJob?.cancel()
return return
} }
}.getOrElse {
cachedPacket.value = null
cachedPacketTimeoutJob?.cancel()
}
} else { } else {
// 有缓存 // 有缓存
val expectingLength = expectingRemainingLength val expectingLength = expectingRemainingLength
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment