From 2091d59219e7b97dc53eecdfcee0ad1e0d1829ce Mon Sep 17 00:00:00 2001 From: NikkyAI Date: Sat, 17 Nov 2018 13:21:12 +0100 Subject: [PATCH] fix async mess --- core/src/main/kotlin/matterlink/api/MessageHandler.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/kotlin/matterlink/api/MessageHandler.kt b/core/src/main/kotlin/matterlink/api/MessageHandler.kt index 1102325..8ea05ef 100644 --- a/core/src/main/kotlin/matterlink/api/MessageHandler.kt +++ b/core/src/main/kotlin/matterlink/api/MessageHandler.kt @@ -21,10 +21,13 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import kotlinx.io.IOException import kotlinx.serialization.json.JSON import kotlinx.serialization.list import matterlink.Logger import java.io.Reader +import java.net.ConnectException +import java.net.MalformedURLException import kotlin.coroutines.CoroutineContext /** @@ -41,7 +44,6 @@ open class MessageHandler : CoroutineScope { private var reconnectCooldown = 0L private var sendErrors = 0 - private var sendChannel: SendChannel = senderActor() private val messageStream = Channel(Channel.UNLIMITED) @@ -93,7 +95,6 @@ open class MessageHandler : CoroutineScope { } } - private suspend fun clear() { val url = "${config.url}/api/messages" val (request, response, result) = url.httpGet() @@ -102,7 +103,8 @@ open class MessageHandler : CoroutineScope { headers["Authorization"] = "Bearer ${config.token}" } } - .awaitStringResponse() +// .awaitStringResponse() + .responseString() when (result) { is Result.Success -> { @@ -121,7 +123,6 @@ open class MessageHandler : CoroutineScope { result.error.exception.printStackTrace() } } - } open suspend fun sendStatusUpdate(message: String) {