fix async mess

This commit is contained in:
NikkyAI 2018-11-17 13:21:12 +01:00
parent f1cc1349ef
commit 2091d59219
1 changed files with 5 additions and 4 deletions

View File

@ -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<ApiMessage> = senderActor()
private val messageStream = Channel<ApiMessage>(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) {