Remove state CONNECTION_LOST

This commit is contained in:
Him188 2021-04-22 12:24:15 +08:00
parent 84fa460b32
commit 035085cf45
3 changed files with 0 additions and 28 deletions

View File

@ -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].
*

View File

@ -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()

View File

@ -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) {