How can i get current web socket session? I had an idea to do something like this:
webSocket("/echo") {
println("WebSocket connection")
val thisConnection = Connection(this)
val session = call.sessions.get<ConnectionToUser>()
if (session == null) {
close(CloseReason(CloseReason.Codes.NORMAL, "User not authorized"))
} else {
call.sessions.set(session.copy(connectionId = thisConnection.id, userId = session.userId))
}
//Some code
}
But i cant set sessions in webSocket.