From 2020e48659c1442c934cc3c3cd28e26ad06bed26 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 26 May 2021 22:33:08 +0600 Subject: [PATCH] fixes of deprecates --- .../kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt | 2 +- .../kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt index 9a22f9f1cfe..10026efc74e 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt @@ -38,7 +38,7 @@ inline fun CoroutineScope.createSafeActionsActor( suspend fun Channel Unit>.doWithSuspending( action: ActorAction ) = suspendCoroutine { - offer { + trySend { safely({ e -> it.resumeWithException(e) }) { it.resume(action()) } diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt index ac265170316..bd7d9a32670 100644 --- a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt +++ b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.collect import kotlinx.serialization.SerializationStrategy private suspend fun DefaultWebSocketSession.checkReceivedAndCloseIfExists() { - if (incoming.poll() != null) { + if (incoming.tryReceive() != null) { close() throw CorrectCloseException }