* StatSvc.Register: Provide SSO Ip and correct logic
* Remove unnessacy launch
Co-authored-by: Him188 <Him188@mamoe.net>
* Test for last polled ip
* Normal login test for last ip
* Fix test failed and remove debug code
* Fix unit test and build
* Optimize pollCurrent and pollAny method
* Use uOldSSOIp and uNewSSOIp only when protocol is PHONE
* Fix bug in toIpV4Long
* Fix new line in NettyBotNormalLoginTest.kt
* Using Inet4Address and toInt method for toIpV4Long
* Return Unsigned Long for toIpV4Long
* Remove unnessacy synchronized annotation
Co-authored-by: Him188 <Him188@mamoe.net>
* Using createAddress method instead of address
* Moving lastDisconnectedIp and lastConnectedIp to Server
List
* Fix build
* Fix build and remove empty line
* Keeping naming consistent
* Use bot.components instead of overrideComponents
Co-authored-by: Him188 <Him188@mamoe.net>
* Revert overrideComponents changes and add comment for overrideComponents
Co-authored-by: Him188 <Him188@mamoe.net>
* Voice serialization
* Implement `hashCode` and `equals` for `Voice`
* Update test
* Update test
* Add note of `PttMessage.pttInternalInstance`
* Fix logic of `Voice.equals`
- Make `AbstractRealNetworkHandlerTest` sealed with subtypes;
- `AbstractNettyNHTest`
- `AbstractNettyNHTestWithSelector`
- Set `mirai.event.launch.undispatched` to `true` for network tests
- Use real `BotOfflineEventMonitor` in tests with selector
* StatSvc.SimpleGet: Decode the resp
* Close network on `StatSvc.SimpleGet.Response.Error`
* Use new `IncomingPacket`
Co-authored-by: Him188 <Him188@mamoe.net>
* Add more comment about GroupAnnouncement.kt
* Edit comment about GroupAnnouncement.kt
Provide experimental api
* Api Dump
* After review
* Change to interface and API dump
* More change
* More change
* More more change
* Some change
* api dump
* Fix name
* Redesign Announcement public api
* Edit comment about GroupAnnouncement.kt
Provide experimental api
* After review
* Change to interface and API dump
* More change
* Modify to extension fun
* Fix sendAnnouncement and change place
* Change Group.deleteAnnouncement to group companion
* fix publish
* Api dump
* Reformat code
* Add `@since 2.7`
* Fix build
Co-authored-by: Him188 <Him188@mamoe.net>
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.
- Remove `FactoryKeepAliveNetworkHandlerSelector` and add `KeepAliveNetworkHandlerSelector`;
- Review the storage of `QQAndroidBotClient`, extract it as a `BotClientHolder`;
- Introduce bot-level components that lasts with the lifecycle of `Bot`, and network-level components accordingly;
- Dynamically re-create the context given to `NetworkHandler` in selector, to use network-level components, including `BotClientHolder`, that allows a simple reinitialization of `BotClient`;
- Handles the situation when physical network broken on logging in, giving a hint to user and halts the log-in process and transfer the responsibility of reconnecting to selector;
- Send logout only in `Bot.close` (manual close).