From 4545146ad53652dd46686ae8b23995bef6bfe6f0 Mon Sep 17 00:00:00 2001 From: Yiqun Zhang Date: Tue, 6 Feb 2024 19:42:24 +0800 Subject: [PATCH] :bug: Fix telnet utils bug --- .../kotlin/com/clipevery/utils/TelnetUtils.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/composeApp/src/desktopMain/kotlin/com/clipevery/utils/TelnetUtils.kt b/composeApp/src/desktopMain/kotlin/com/clipevery/utils/TelnetUtils.kt index c344db205..f2248132e 100644 --- a/composeApp/src/desktopMain/kotlin/com/clipevery/utils/TelnetUtils.kt +++ b/composeApp/src/desktopMain/kotlin/com/clipevery/utils/TelnetUtils.kt @@ -5,9 +5,9 @@ import com.clipevery.net.ClipClient import io.github.oshai.kotlinlogging.KotlinLogging import io.ktor.http.URLProtocol import io.ktor.http.path +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async import kotlinx.coroutines.selects.select -import kotlinx.coroutines.withContext class TelnetUtils(private val clipClient: ClipClient) { @@ -17,11 +17,9 @@ class TelnetUtils(private val clipClient: ClipClient) { if (hostInfoList.isEmpty()) { return null } - val deferredArray = withContext(ioDispatcher) { - hostInfoList.map { hostInfo -> - async { - if (telnet(hostInfo, port, timeout)) hostInfo else null - } + val deferredArray = hostInfoList.map { hostInfo -> + CoroutineScope(ioDispatcher).async { + if (telnet(hostInfo, port, timeout)) hostInfo else null } }