From e270b05d5800788969694b62edd62b2e9e2749f5 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Mon, 30 May 2022 20:43:19 +0200 Subject: [PATCH] replace runCatching exception swallow --- .../kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt index d1d068a..93f5672 100644 --- a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt @@ -4,6 +4,7 @@ import java.net.Socket import kotlin.random.Random import kotlin.random.nextUInt import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.asFlow @@ -11,6 +12,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.runBlocking import kotlinx.coroutines.supervisorScope +import kotlinx.coroutines.withContext class KtRconClient( private val host: String, @@ -88,7 +90,7 @@ class KtRconClient( // put(p.terminator) // } - runCatching { + withContext(Dispatchers.IO) { socket.getOutputStream().use { os -> os.write(bb.array()) os.flush()