Better session management + logs

This commit is contained in:
Robinson 2023-10-26 09:30:11 +02:00
parent 70825708a3
commit 9d303beade
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 14 additions and 2 deletions

View File

@ -40,20 +40,32 @@ open class Session<CONNECTION: SessionConnection>(@Volatile var connection: CONN
/**
* the FIRST time this method is called, it will be true. EVERY SUBSEQUENT TIME, it will be false
*/
@Volatile
internal var isNewSession = true
private set
get() {
val orig = field
if (orig) {
field = false
newSession = false
}
return orig
}
@Volatile
private var newSession = true
fun restore(connection: CONNECTION) {
this.connection = connection
connection.logger.debug("[{}] restoring connection", connection)
if (newSession) {
connection.logger.debug("[{}] Session connection established", connection)
return
}
connection.logger.debug("[{}] Restoring session connection", connection)
lock.withLock {
val oldProxyObjects = oldProxyObjects
@ -78,7 +90,7 @@ open class Session<CONNECTION: SessionConnection>(@Volatile var connection: CONN
}
fun save(connection: CONNECTION) {
connection.logger.debug("[{}] saving connection", connection)
connection.logger.debug("[{}] Saving session connection", connection)
val rmi = connection.rmi
val allProxyObjects = rmi.getAllProxyObjects()