codec
08/14/2020, 8:09 AMDefaultWebSocketSession
objects?
For example, in my Application.Kt
class, I have:
webSocket("/update") {
connections += this
try {
while (true) {
when (val frame = incoming.receive()) {
is Frame.Text -> {
val text = frame.readText()
// Send message to all the connections, except the messenger connection.
for (conn in connections) {
if (conn != this) {
conn.outgoing.send(Frame.Text(text))
}
}
}
}
}
} catch (e: ClosedReceiveChannelException) {
<http://log.info|log.info>("connection closed. ignore.")
}
finally {
connections -= this
}
}
}
So, what I’m trying to accomplish works there, in that class, but not elsewhere in other application classes. When I just have a list of connection objects, or DefaultWebSocketSession
objects?Wilfred
08/14/2020, 9:06 PMcodec
08/14/2020, 10:46 PMMap<SessionId,DefaultWebSocketSession>
, injected that where it needed to be for the logic.