Julius
06/10/2022, 1:09 AMfor (frame in incoming) {
val data = receiveDeserialized<Data>()
println(data)
}
This is pretty much what I'd like to do, but the for (frame in incoming)
part already consumes data from the queue, so I'm kinda confused how to properly iterate over itJulius
06/10/2022, 1:33 AMwhile (true) {
try {
val data = receiveDeserialized<Data>()
println(deckInfo)
} catch (ClosedReceiveChannelException: Exception) {
break
}
}
This is what I came up as a solution, but it seems very unelegantDavid Stibbe
06/10/2022, 7:22 AMfor (frame in incoming) {
if (frame is Frame.Text) {
val text = frame.readText()
// ... deserialize the text using a jackson object mapper
}
}
Like this?Aleksei Tirman [JB]
06/10/2022, 8:30 AMJulius
06/10/2022, 1:05 PMdeserialize
function of WebSocketConverter
.
It further says that "`WebSocketConverter` is accessible as property in WebSocketSession
".
I sadly still don't quite understand how to access WebSocketConverter
😬David Stibbe
06/10/2022, 1:17 PMfor (frame in incoming) {
val item = converter?.deserialize(
charset = Charset.forName("UTF-8"),
typeInfo = typeInfo<SomeThing>() ,
content = frame)
// do stuff
}
Example how you can deserialize (SomeThing in this case)Julius
06/10/2022, 1:41 PMDavid Stibbe
06/10/2022, 1:41 PM