Antanas A.
02/21/2019, 9:11 AMsuspend fun connectToSocket() {
suspend fun process(session: DefaultClientWebSocketSession) {
while (session.isActive) {
session.incoming.onReceiveOrNull { frame ->
if (frame == null) {
session.close()
delay(2000)
connectToSocket() // <- do reconnect
}
}
}
}
process(startSession())
}
connectToSocket()
spand
02/21/2019, 9:39 AMsuspend fun connectToSocket() {
suspend fun process(session: DefaultClientWebSocketSession) {
while (session.isActive) {
session.incoming.onReceiveOrNull { frame ->
if (frame == null) {
session.close()
}
}
}
}
process(startSession())
}
while (true){
connectToSocket()
delay(2000)
}
Antanas A.
02/21/2019, 10:01 AMspand
02/21/2019, 10:04 AMprocess
function is a problem why dont you just remove/inline it ?Antanas A.
02/21/2019, 10:06 AMwhen (uri.protocol.isSecure()) {
true -> client.wss(host = uri.host, port = uri.port, path = uri.encodedPath) { process(this) }
false -> <http://client.ws|client.ws>(host = uri.host, port = uri.port, path = uri.encodedPath) { process(this) }
}