From a4ccbd4b6a7d99675b862d52fc42129e075c8644 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 22 Sep 2020 21:06:31 +0200 Subject: [PATCH] Cleaned up comments. Cleaned up forEachConnection() (it's only on server now) --- src/dorkbox/network/Server.kt | 2 +- src/dorkbox/network/connection/EndPoint.kt | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/dorkbox/network/Server.kt b/src/dorkbox/network/Server.kt index 7808a0bd..b3f6c4da 100644 --- a/src/dorkbox/network/Server.kt +++ b/src/dorkbox/network/Server.kt @@ -585,7 +585,7 @@ open class Server(config: ServerConfiguration = ServerC } /** - * Execute the unit function against all existing connections + * Runs an action for each connection */ fun forEachConnection(function: (connection: CONNECTION) -> Unit) { connections.forEach { diff --git a/src/dorkbox/network/connection/EndPoint.kt b/src/dorkbox/network/connection/EndPoint.kt index 4e2d8618..077277fa 100644 --- a/src/dorkbox/network/connection/EndPoint.kt +++ b/src/dorkbox/network/connection/EndPoint.kt @@ -336,20 +336,10 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A } } - /** - * Runs an action for each connection - */ - suspend fun forEachConnection(function: suspend (connection: CONNECTION) -> Unit) { - connections.forEach { - function(it) - } - } - - @Suppress("DuplicatedCode") // note: CANNOT be called in action dispatch. ALWAYS ON SAME THREAD internal suspend fun writeHandshakeMessage(publication: Publication, message: HandshakeMessage) { - // The sessionId is globally unique, and is assigned by the server. + // The handshake sessionId IS NOT globally unique logger.trace { "[${publication.sessionId()}] send HS: $message" } @@ -419,7 +409,7 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A return message } catch (e: Exception) { - // The sessionId is globally unique, and is assigned by the server. + // The handshake sessionId IS NOT globally unique val sessionId = header.sessionId() val exception = newException("[${sessionId}] Error de-serializing message", e) @@ -452,7 +442,7 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A "[${header.sessionId()}] received: $message" } } catch (e: Exception) { - // The sessionId is globally unique, and is assigned by the server. + // The handshake sessionId IS NOT globally unique val sessionId = header.sessionId() val exception = newException("[${sessionId}] Error de-serializing message", e) @@ -519,7 +509,7 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A // NOTE: this **MUST** stay on the same co-routine that calls "send". This cannot be re-dispatched onto a different coroutine! @Suppress("DuplicatedCode") internal suspend fun send(message: Any, publication: Publication, connection: Connection) { - // The sessionId is globally unique, and is assigned by the server. + // The handshake sessionId IS NOT globally unique logger.trace { "[${publication.sessionId()}] send: $message" }