Sourabh Rawat
12/08/2020, 12:37 PMfun main() = runBlocking {
val httpClient = HttpClient {
install(Logging) {
level = LogLevel.ALL
}
@OptIn(KtorExperimentalAPI::class)
install(WebSockets)
expectSuccess = false
install(JsonFeature) {
@OptIn(KtorExperimentalAPI::class)
acceptContentTypes = listOf(ContentType("application", "json-rpc"))
serializer = KotlinxSerializer()
}
}
val wss =httpClient.webSocketSession(method = HttpMethod.Get, host = "127.0.0.1", port = 6800, path = "/jsonrpc")
wss.close()
}
this does not stop the program. what am I doing wrong?wss.close()
?Saul Wiggin
12/08/2020, 1:12 PMwws.close()
closes the websocket. If you want to cancel the coroutine to stop the program then you could use main.cancel()
Sourabh Rawat
12/08/2020, 1:16 PMwss.close
to close the coruotune. What I want is that the main finishes which doesn't if I use this wss snippet. If I replace all wss code with just println, then main finishes
Joris PZ
12/08/2020, 2:15 PMwebsocketSession
suspends until the connection is established, and so main
wouldn't finish until it doesBig Chungus
12/08/2020, 3:04 PMfun main() = runBlocking{}
you can do suspend fun main() {}
Sourabh Rawat
12/08/2020, 3:13 PMsuspend mani
recent feature?Big Chungus
12/08/2020, 6:17 PMandylamax
12/09/2020, 12:33 AM