Hello guys, I am currently trying to connect our K...
# announcements
t
Hello guys, I am currently trying to connect our Kotlin Multiplatform Project to websockets. I would like to use ktor-websockets library to receive some updates from our backend but onfortunately when I run this code, nothing happens:
Copy code
client.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
b
#C0A974TJ9
👍 1