Tony Blundell
12/05/2020, 7:52 PMclass WsClient {
private val url = "<http://example.com>"
private val httpClient = HttpClient { install(WebSockets) }
suspend fun start() {
httpClient.wss(HttpMethod.Get, url) {
send("Hello")
while (true) {
when (val frame = incoming.receive()) {
is Frame.Text -> println(frame.readText())
is Frame.Binary -> println(frame.readBytes())
}
}
}
}
}
fun main() = runBlocking {
WsClient().start()
}
Matteo Mirk
12/07/2020, 9:07 AMTony Blundell
12/07/2020, 9:08 AM