mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-04 02:53:48 +08:00
a38f24cbe5
Reconnection is directed by `BotOfflineEvent`. ### Event Broadcasting - PacketFactory `MessageSvcPushForceOffline` closes network with `ForceOfflineException`. - `network.close(cause)` pass the cause to state observer from `QQAndroidBot.stateObserverChain`, the observer broadcasts as follows: - Nothing if `cause` is `ForceOfflineException` or `BotClosedByEvent`(which is broadcast by user) - `BotOfflineEvent.Dropped` if cause is NetworkException and is recoverable(which is from Netty handlers) - `BotOfflineEvent.Force` if cause is `ForceOfflineException` is from the factory mentioned above. - `BotOfflineEvent.Active` otherwise(any other unexpected exceptions considered as an error) ### Deciding whether to reconnect User can listen and change `BotOfflineEvent.reconnect` to decide. Default values are determined by `BotConfiguration`. ### Event listening - Component `BotOfflineEventMonitor` listens `BotOfflineEvent`, logs the event for users, and launches a coroutine to do `network.resumeConnection` to notify the selector to renew an instance. - `BotOnlineWatchdog` in `SelectorNetworkHandler` is removed. - Selector now handles `maxAttempts` correctly in such a way that `awaitResumeInstance` does not throw exception until maximum attempts reached. - On every attempt, new exceptions are logged to provide debugging information, and further duplications are ignored. |
||
---|---|---|
.. | ||
androidMain/kotlin | ||
commonMain/kotlin | ||
commonTest/kotlin | ||
jvmMain | ||
jvmTest/kotlin | ||
main |