Cleaned up comments. Cleaned up forEachConnection() (it's only on server now)
This commit is contained in:
parent
0a3a08fb8f
commit
a4ccbd4b6a
|
@ -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) {
|
fun forEachConnection(function: (connection: CONNECTION) -> Unit) {
|
||||||
connections.forEach {
|
connections.forEach {
|
||||||
|
|
|
@ -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")
|
@Suppress("DuplicatedCode")
|
||||||
// note: CANNOT be called in action dispatch. ALWAYS ON SAME THREAD
|
// note: CANNOT be called in action dispatch. ALWAYS ON SAME THREAD
|
||||||
internal suspend fun writeHandshakeMessage(publication: Publication, message: HandshakeMessage) {
|
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 {
|
logger.trace {
|
||||||
"[${publication.sessionId()}] send HS: $message"
|
"[${publication.sessionId()}] send HS: $message"
|
||||||
}
|
}
|
||||||
|
@ -419,7 +409,7 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A
|
||||||
|
|
||||||
return message
|
return message
|
||||||
} catch (e: Exception) {
|
} 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 sessionId = header.sessionId()
|
||||||
|
|
||||||
val exception = newException("[${sessionId}] Error de-serializing message", e)
|
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"
|
"[${header.sessionId()}] received: $message"
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} 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 sessionId = header.sessionId()
|
||||||
|
|
||||||
val exception = newException("[${sessionId}] Error de-serializing message", e)
|
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!
|
// NOTE: this **MUST** stay on the same co-routine that calls "send". This cannot be re-dispatched onto a different coroutine!
|
||||||
@Suppress("DuplicatedCode")
|
@Suppress("DuplicatedCode")
|
||||||
internal suspend fun send(message: Any, publication: Publication, connection: Connection) {
|
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 {
|
logger.trace {
|
||||||
"[${publication.sessionId()}] send: $message"
|
"[${publication.sessionId()}] send: $message"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user