Is there any websocket ktor client example, in which the entry object is available so it can be used to cancel or start the websocket session. So far, there is that example where you manage the websocket session within a scoped block of code and it isn't available to the outside world.
Azur Haljeta
11/23/2020, 9:30 AM
Copy code
httpClient.wss(
method = HttpMethod.Get,
host = "<http://echo.websocket.org|echo.websocket.org>",
port = 8090,
) {
// this is of 'DefaultClientWebSocketSession' type
val frame = incoming.receive()
when (frame) {
is Frame.Text -> println(frame.readText())
is Frame.Binary -> println(frame.readBytes())
}
}
but what I need as reference, like this:
Copy code
val someWsObject = httpClient.wss(
method = HttpMethod.Get,
host = "<http://echo.websocket.org|echo.websocket.org>",
port = 8090,
)
someWsObject.connect()
val frame = someWsObject.incoming.receive()
when (frame) {
is Frame.Text -> println(frame.readText())
is Frame.Binary -> println(frame.readBytes())
}