mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 14:20:24 +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
|
// 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> =
|
final override val eventChannel: EventChannel<BotEvent> =
|
||||||
GlobalEventChannel.filterIsInstance<BotEvent>().filter { it.bot === this@AbstractBot }
|
GlobalEventChannel.filterIsInstance<BotEvent>().filter { it.bot === this@AbstractBot }
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ internal abstract class AbstractBot constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.reconnect) {
|
if (event.reconnect) {
|
||||||
if (network.state != NetworkHandler.State.OK) {
|
if (!network.isOk()) {
|
||||||
// normally closed
|
// normally closed
|
||||||
return@subscribeAlways
|
return@subscribeAlways
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@ internal class NetworkHandlerContextImpl(
|
|||||||
internal interface NetworkHandler {
|
internal interface NetworkHandler {
|
||||||
val context: NetworkHandlerContext
|
val context: NetworkHandlerContext
|
||||||
|
|
||||||
|
fun isOk() = state == State.OK
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State of this handler.
|
* State of this handler.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user