mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-07 16:40:43 +08:00
Add NetworkHandler.isOk to avoid state == OK
This commit is contained in:
parent
4446479e80
commit
8786f12d5d
@ -73,7 +73,7 @@ internal abstract class AbstractBot constructor(
|
||||
// overrides
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
final override val isOnline: Boolean get() = network.state == NetworkHandler.State.OK
|
||||
final override val isOnline: Boolean get() = network.isOk()
|
||||
final override val eventChannel: EventChannel<BotEvent> =
|
||||
GlobalEventChannel.filterIsInstance<BotEvent>().filter { it.bot === this@AbstractBot }
|
||||
|
||||
@ -144,7 +144,7 @@ internal abstract class AbstractBot constructor(
|
||||
}
|
||||
|
||||
if (event.reconnect) {
|
||||
if (network.state != NetworkHandler.State.OK) {
|
||||
if (!network.isOk()) {
|
||||
// normally closed
|
||||
return@subscribeAlways
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ internal class NetworkHandlerContextImpl(
|
||||
internal interface NetworkHandler {
|
||||
val context: NetworkHandlerContext
|
||||
|
||||
fun isOk() = state == State.OK
|
||||
|
||||
/**
|
||||
* State of this handler.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user