Reconnects during a disconnect are now re-dispatched appropriately

This commit is contained in:
Robinson 2023-03-02 19:46:08 +01:00
parent 559880b71c
commit 1bdb5d546d
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C

View File

@ -366,6 +366,21 @@ open class Client<CONNECTION : Connection>(
connectionTimeoutSec: Int = 30, connectionTimeoutSec: Int = 30,
reliable: Boolean = true) reliable: Boolean = true)
{ {
// NOTE: We CAN have a 'connect' inside the 'disconnect' callback (as a reconnect feature). THIS WILL CAUSE PROBLEMS!
// there can ALSO be recursion problems, so we must address that.
if (eventDispatch.isCurrent && !eventDispatch.wasForced) {
logger.trace { "Redispatching a connect request!" }
eventDispatch.forceLaunch {
connect(remoteAddress,
remoteAddressString,
remoteAddressPrettyString,
ipcId,
connectionTimeoutSec,
reliable)
}
return
}
// NOTE: it is critical to remember that Aeron DOES NOT like running from coroutines! // NOTE: it is critical to remember that Aeron DOES NOT like running from coroutines!
config as ClientConfiguration config as ClientConfiguration