Cleaned up ordering of connection initialization

This commit is contained in:
Robinson 2023-09-28 01:55:03 +02:00
parent b55168a3eb
commit 0825274bd0
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
2 changed files with 3 additions and 4 deletions

View File

@ -804,8 +804,6 @@ open class Client<CONNECTION : Connection>(config: ClientConfiguration = ClientC
logger.debug("[${handshakeConnection.details}] (${handshake.connectKey}) Connection (${newConnection.id}) to [$addressString] done with handshake.")
}
newConnection.setImage()
// in the specific case of using sessions, we don't want to call 'init' or `connect` for a connection that is resuming a session
var newSession = true
if (sessionManager.enabled()) {
@ -813,6 +811,7 @@ open class Client<CONNECTION : Connection>(config: ClientConfiguration = ClientC
newSession = sessionManager.onInit(newConnection as SessionConnection)
}
newConnection.setImage()
// before we finish creating the connection, we initialize it (in case there needs to be logic that happens-before `onConnect` calls
if (newSession) {

View File

@ -133,8 +133,6 @@ internal class ServerHandshake<CONNECTION : Connection>(
logger.debug("[${newConnection}] (${message.connectKey}) Connection done with handshake.")
}
newConnection.setImage()
// in the specific case of using sessions, we don't want to call 'init' or `connect` for a connection that is resuming a session
var newSession = true
if (server.sessionManager.enabled()) {
@ -142,6 +140,8 @@ internal class ServerHandshake<CONNECTION : Connection>(
newSession = server.sessionManager.onInit(newConnection as SessionConnection)
}
newConnection.setImage()
// before we finish creating the connection, we initialize it (in case there needs to be logic that happens-before `onConnect` calls
if (newSession) {
listenerManager.notifyInit(newConnection)