Azur Haljeta
11/23/2020, 9:30 AMhttpClient.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:
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())
}
Joris PZ
11/23/2020, 4:19 PMedenman
11/23/2020, 7:39 PMprivate var webSocketSession: DefaultClientWebSocketSession? = null
and I do webSocketSession = this
first thing inside my block
Azur Haljeta
11/24/2020, 7:37 AMbbaldino
11/28/2020, 11:36 PMHttpClient#webSocketSession
method which returns a DefaultClientWebSocketSession
. There's a close
method on that which can be used to stop it, and I defined an extension method on DefaultClientWebSocketSession
in my class to start/run the message handling loop.