mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-22 13:46:13 +08:00
Remove state CONNECTION_LOST
This commit is contained in:
parent
84fa460b32
commit
035085cf45
@ -72,15 +72,6 @@ internal interface NetworkHandler {
|
||||
*/
|
||||
OK,
|
||||
|
||||
/**
|
||||
* No Internet Connection available or for any other reasons
|
||||
* but it is possible to establish a connection again(switching state to [CONNECTING]).
|
||||
*
|
||||
* At this state [resumeConnection] turns the handle to [CONNECTING].
|
||||
* [sendAndExpect] throws [IllegalStateException]
|
||||
*/
|
||||
CONNECTION_LOST,
|
||||
|
||||
/**
|
||||
* Cannot resume anymore. Both [resumeConnection] and [sendAndExpect] throw a [CancellationException].
|
||||
*
|
||||
|
@ -47,7 +47,6 @@ internal abstract class AbstractKeepAliveNetworkHandlerSelector<H : NetworkHandl
|
||||
this.current.compareAndSet(current, null) // invalidate the instance and try again.
|
||||
awaitResumeInstance() // will create new instance.
|
||||
}
|
||||
NetworkHandler.State.CONNECTION_LOST,
|
||||
NetworkHandler.State.CONNECTING,
|
||||
NetworkHandler.State.INITIALIZED -> {
|
||||
current.resumeConnection()
|
||||
|
@ -317,24 +317,6 @@ internal class NettyNetworkHandler(
|
||||
override fun toString(): String = "StateOK"
|
||||
}
|
||||
|
||||
private inner class StateConnectionLost(
|
||||
private val cause: Throwable?
|
||||
) : NettyState(State.CONNECTION_LOST) {
|
||||
override fun getCause(): Throwable? = cause
|
||||
|
||||
override suspend fun sendPacketImpl(packet: OutgoingPacket) {
|
||||
throw IllegalStateException(
|
||||
"Internal error: connection is lost so cannot send packet. Call resumeConnection first.",
|
||||
cause
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun resumeConnection0() {
|
||||
setState { StateConnecting(ExceptionCollector(cause)) }
|
||||
.resumeConnection()
|
||||
} // noop
|
||||
}
|
||||
|
||||
private inner class StateClosed(
|
||||
val exception: Throwable?
|
||||
) : NettyState(State.CLOSED) {
|
||||
|
Loading…
Reference in New Issue
Block a user