mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 14:44:48 +08:00
Close network in MessageSvcPushForceOffline properly by throwing ServerClosedException
This commit is contained in:
parent
0d28772275
commit
7739c4db80
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.network.impl.netty
|
||||
|
||||
import net.mamoe.mirai.internal.network.handler.selector.NetworkException
|
||||
|
||||
internal data class ServerClosedException(
|
||||
override val message: String? = null,
|
||||
override val cause: Throwable? = null
|
||||
) : NetworkException(true)
|
@ -12,6 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.packet.chat.receive
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.event.events.BotOfflineEvent
|
||||
import net.mamoe.mirai.internal.QQAndroidBot
|
||||
import net.mamoe.mirai.internal.network.impl.netty.ServerClosedException
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.RequestPushForceOffline
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readUniPacket
|
||||
@ -29,6 +30,6 @@ internal object MessageSvcPushForceOffline :
|
||||
}
|
||||
|
||||
override suspend fun QQAndroidBot.handle(packet: BotOfflineEvent.Force) {
|
||||
network.close(IllegalStateException("Closed by MessageSvc.PushForceOffline: $packet"))
|
||||
network.close(ServerClosedException("Closed by MessageSvc.PushForceOffline: $packet"))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user