fix async mess
This commit is contained in:
parent
f1cc1349ef
commit
2091d59219
|
@ -21,10 +21,13 @@ import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.io.IOException
|
||||||
import kotlinx.serialization.json.JSON
|
import kotlinx.serialization.json.JSON
|
||||||
import kotlinx.serialization.list
|
import kotlinx.serialization.list
|
||||||
import matterlink.Logger
|
import matterlink.Logger
|
||||||
import java.io.Reader
|
import java.io.Reader
|
||||||
|
import java.net.ConnectException
|
||||||
|
import java.net.MalformedURLException
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +44,6 @@ open class MessageHandler : CoroutineScope {
|
||||||
private var reconnectCooldown = 0L
|
private var reconnectCooldown = 0L
|
||||||
private var sendErrors = 0
|
private var sendErrors = 0
|
||||||
|
|
||||||
|
|
||||||
private var sendChannel: SendChannel<ApiMessage> = senderActor()
|
private var sendChannel: SendChannel<ApiMessage> = senderActor()
|
||||||
|
|
||||||
private val messageStream = Channel<ApiMessage>(Channel.UNLIMITED)
|
private val messageStream = Channel<ApiMessage>(Channel.UNLIMITED)
|
||||||
|
@ -93,7 +95,6 @@ open class MessageHandler : CoroutineScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private suspend fun clear() {
|
private suspend fun clear() {
|
||||||
val url = "${config.url}/api/messages"
|
val url = "${config.url}/api/messages"
|
||||||
val (request, response, result) = url.httpGet()
|
val (request, response, result) = url.httpGet()
|
||||||
|
@ -102,7 +103,8 @@ open class MessageHandler : CoroutineScope {
|
||||||
headers["Authorization"] = "Bearer ${config.token}"
|
headers["Authorization"] = "Bearer ${config.token}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.awaitStringResponse()
|
// .awaitStringResponse()
|
||||||
|
.responseString()
|
||||||
|
|
||||||
when (result) {
|
when (result) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
|
@ -121,7 +123,6 @@ open class MessageHandler : CoroutineScope {
|
||||||
result.error.exception.printStackTrace()
|
result.error.exception.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open suspend fun sendStatusUpdate(message: String) {
|
open suspend fun sendStatusUpdate(message: String) {
|
||||||
|
|
Loading…
Reference in New Issue