Ktor server, a correct way to receive messages from websocket
I'm new in Ktor-server and don't fully understand how web sockets receive messages. I found several solutions in different sources. (try\catch and webscoket blocks are omitted)
while(true) way
while(true){
val incoming = receiveDeserialized()
MessageService.newMessage(incoming)
}
consumeEach way
incoming.consumeEach { frame ->
// process frame
}
flow way
incoming.receiveAsFlow().filterIsInstance()...