mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-07 16:40:43 +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. |
||
---|---|---|
.. | ||
src | ||
build.gradle.kts | ||
README.md |
mirai-core-utils
内部工具类模块。提供二进制兼容而不提供源码兼容,但也不保证破坏性变更不会发生,因此若要使用该工具模块,请自行承担兼容后果。