mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-10 20:20:08 +08:00
Fix structure end reading
This commit is contained in:
parent
db7d0e8372
commit
432a8690b1
@ -308,10 +308,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
|
||||
input: JceInput
|
||||
) : JceDecoder(input) {
|
||||
override fun endStructure(desc: SerialDescriptor) {
|
||||
while (input.peakHead().type != STRUCT_END) {
|
||||
input.readHead()
|
||||
while (input.input.canRead() && input.peakHeadOrNull()?.type != STRUCT_END) {
|
||||
input.readHeadOrNull() ?: return
|
||||
}
|
||||
input.readHead()
|
||||
input.readHeadOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,6 +513,9 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
|
||||
@PublishedApi
|
||||
internal fun peakHead(): JceHead = input.makeView().readHead() ?: error("no enough data to read head")
|
||||
|
||||
@PublishedApi
|
||||
internal fun peakHeadOrNull(): JceHead? = input.makeView().readHead()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE") // 避免 stacktrace 出现两个 readHead
|
||||
private inline fun IoBuffer.readHead(): JceHead? {
|
||||
if (endOfInput) return null
|
||||
|
@ -349,7 +349,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
// 不要 `withTimeout`. timeout 的异常会不知道去哪了.
|
||||
} ?: net.mamoe.mirai.qqandroid.utils.inline {
|
||||
packetListeners.remove(handler)
|
||||
error("timeout when sending $commandName")
|
||||
error("timeout when receiving response of $commandName")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user