mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-23 22:00:10 +08:00
Set state to CLOSED on failure during connecting
This commit is contained in:
parent
23b296692e
commit
b62e39b4d1
@ -229,10 +229,11 @@ internal open class NettyNetworkHandler(
|
||||
return@invokeOnCompletion // already been switching to CONNECTING
|
||||
}
|
||||
setState(null) { // ignore replication check
|
||||
StateConnecting(
|
||||
collectiveExceptions.apply { collect(error) },
|
||||
wait = true
|
||||
)
|
||||
// StateConnecting(
|
||||
// collectiveExceptions.apply { collect(error) },
|
||||
// wait = true
|
||||
// )
|
||||
StateClosed(collectiveExceptions.collectGet(error))
|
||||
} // logon failure closes the network handler.
|
||||
}
|
||||
// and this error will also be thrown by `StateConnecting.resumeConnection`
|
||||
@ -265,6 +266,15 @@ internal open class NettyNetworkHandler(
|
||||
protected inner class StateLoading(
|
||||
private val connection: NettyChannel
|
||||
) : NettyState(State.LOADING) {
|
||||
init {
|
||||
coroutineContext.job.invokeOnCompletion {
|
||||
if (it != null && it !is CancellationException && it !is StateSwitchingException) {
|
||||
connection.close()
|
||||
setState { StateClosed(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun sendPacketImpl(packet: OutgoingPacket): Boolean {
|
||||
connection.writeAndFlush(packet)
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user