Michael
04/30/2021, 5:06 PMclient.webSocket(
port = 80,
method = HttpMethod.Get,
host = "<https://uat-betws.sts.pl>",
path = "/ticket?token=eyJzdWIiOiI0ZmY5Y2E1Mi02ZmEwLTRiYWYtODlhYS0wODM1NGE2MTU0YjYiLCJpYXQiOjE2MTk4MDAwNzgsImV4cCI6MTYxOTgwMzY3OH0.oIaXH-nFDpMklp4FSJWMtsM7ECSIfuNF99tTQxiEALM"
)
{
for (message in incoming) {
message as? Frame.Text ?: continue
val receivedText = message.readText()
println(receivedText)
}
// Consume all incoming websockets on this url
this.incoming.consumeAsFlow().collect {
logger.d("Received ticket status websocket of type ${it.frameType.name}")
if (it is Frame.Text) {
Json.decodeFromString<TicketStatusResponse>(it.readText())
}
}
}
Does somebody have any experience with ktor-websockets library? There is almost no documentation so maybe I am doing something wrong.
Thank you
Thread in #generalMichael
04/30/2021, 5:09 PMTom Wayne
04/30/2021, 5:11 PMTom Wayne
04/30/2021, 5:12 PMMichael
04/30/2021, 5:15 PMAnd I dont send any kind of payload to the websockets. I am just trying to receive data from it.I meant the server side code sending it to the client
Tom Wayne
04/30/2021, 5:16 PMMichael
04/30/2021, 5:18 PMmessage as? Frame.Text ?: continue
never runs at all?Tom Wayne
04/30/2021, 5:23 PMMichael
04/30/2021, 5:39 PMMichael
04/30/2021, 5:42 PMMichael
04/30/2021, 5:43 PMclient.webSocket("<wss://echo.websocket.org/?encoding=text>") {
launch {
outgoing.send(Frame.Text("Test"))
}
for (frame in incoming) {
println(frame)
if (frame is Frame.Text) {
println(frame.readText())
}
}
}
Michael
04/30/2021, 5:43 PMTom Wayne
04/30/2021, 5:43 PMTom Wayne
05/02/2021, 6:10 PMMichael
05/02/2021, 6:13 PMTom Wayne
05/02/2021, 7:18 PMTom Wayne
05/03/2021, 9:21 AMTom Wayne
05/03/2021, 9:21 AM