Fix FriendListPacket

This commit is contained in:
Him188 2020-01-30 18:49:20 +08:00
parent efb662a978
commit a2d652b50f
3 changed files with 9 additions and 5 deletions

View File

@ -31,6 +31,10 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
override val bot: QQAndroidBot by bot.unsafeWeakRef()
override val supervisor: CompletableJob = SupervisorJob(bot.coroutineContext[Job])
override val coroutineContext: CoroutineContext = bot.coroutineContext + CoroutineExceptionHandler { _, throwable ->
throwable.logStacktrace("Exception in NetworkHandler")
}
private lateinit var channel: PlatformSocket
override suspend fun login() {
@ -316,7 +320,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
packetListeners.addLast(handler)
bot.logger.info("Send: ${this.commandName}")
channel.send(delegate)
return withTimeoutOrNull(3000) {
return withTimeout(3000) {
@Suppress("UNCHECKED_CAST")
handler.await() as E
} ?: net.mamoe.mirai.qqandroid.utils.inline {
@ -337,6 +341,4 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
}
override suspend fun awaitDisconnection() = supervisor.join()
override val coroutineContext: CoroutineContext = bot.coroutineContext
}

View File

@ -3,8 +3,6 @@ package net.mamoe.mirai.qqandroid.network.protocol.data.jce
import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable
import net.mamoe.mirai.qqandroid.io.JceStruct
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Vec0xd50
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Vec0xd6b
@Serializable
internal class GetFriendListReq(