Cleaned up comments. Cleaned up forEachConnection() (it's only on server now)

This commit is contained in:
nathan 2020-09-22 21:06:31 +02:00
parent 0a3a08fb8f
commit a4ccbd4b6a
2 changed files with 5 additions and 15 deletions

View File

@ -585,7 +585,7 @@ open class Server<CONNECTION : Connection>(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 {

View File

@ -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"
}