Fábio Carneiro
03/25/2021, 2:56 PMDefaultWebSockerServerSession
is already a 1:1 connection between the server and client?Joost Klitsie
03/25/2021, 2:58 PMFábio Carneiro
03/25/2021, 3:26 PMsend()
? Is it broadcast then?Joost Klitsie
03/25/2021, 3:28 PMFábio Carneiro
03/25/2021, 3:39 PMfor (frame in incoming) {
incoming
is a receivechannel and what I am basically doing is configuring a callback for every frame I receiveJoost Klitsie
03/25/2021, 4:01 PMwebSocket("websocket/path") {
addActiveSession(this) // whatever you want, just store the session
incoming.receiveAsFlow().collect { frame ->
// Handle incoming stuff, or just wait until this is cancelled (aka session ended)
}
removeFromActiveSessions(this)
}
sessions.forEach { session ->
if (session.isActive) {
connection.outgoing.send(Frame.Binary(true, bytes)) // bytes is in my case a json object converted to byte array
} else {
removeFromActiveSessions(session)
}
}
Fábio Carneiro
03/25/2021, 5:17 PM