Blocking pass packets to handlers

This commit is contained in:
Him188 2019-10-09 23:53:42 +08:00 committed by GitHub
parent a64123bdbf
commit f7cdbbde2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,19 +124,11 @@ internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
if (ServerPacketReceivedEvent(bot, packet).broadcast().cancelled) {
return
}
withContext(CoroutineExceptionHandler { _, e -> e.printStackTrace() }) {
launch(this.coroutineContext) {
loginHandler.onPacketReceived(packet)
}
packetHandlers.forEach {
launch(this.coroutineContext) {
it.instance.onPacketReceived(packet)
}
}
}//awaits all coroutines launched in this block
loginHandler.onPacketReceived(packet)
packetHandlers.forEach {
it.instance.onPacketReceived(packet)
}
}
private var socket: DatagramSocket? = null