mirai/mirai-core-api/src
Him188 a38f24cbe5 Redesign connection maintenance mechanism:
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.
2021-06-16 16:58:20 +08:00
..
androidMain/kotlin Fix ignored exceptions in PlatformLogger on Android 2021-04-05 23:58:37 +08:00
commonMain/kotlin Redesign connection maintenance mechanism: 2021-06-16 16:58:20 +08:00
commonTest/kotlin Kotlin 1.5 and dependencies updates (#1246) 2021-05-27 14:39:13 +08:00
jvmMain Fix the resource leak when closing TxCaptchaHelper(Swing) directly 2021-06-01 12:47:42 +08:00
jvmTest/kotlin Introduce AbstractEventTest 2021-06-07 18:56:33 +08:00
main Rearrange protocol implementations 2020-11-01 15:07:32 +08:00