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) { if (ServerPacketReceivedEvent(bot, packet).broadcast().cancelled) {
return return
} }
withContext(CoroutineExceptionHandler { _, e -> e.printStackTrace() }) { loginHandler.onPacketReceived(packet)
launch(this.coroutineContext) { packetHandlers.forEach {
loginHandler.onPacketReceived(packet) it.instance.onPacketReceived(packet)
} }
packetHandlers.forEach {
launch(this.coroutineContext) {
it.instance.onPacketReceived(packet)
}
}
}//awaits all coroutines launched in this block
} }
private var socket: DatagramSocket? = null private var socket: DatagramSocket? = null