From 856d753c7f335dacd9cc4daf666a152378886200 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 16 Apr 2019 18:07:11 +0200 Subject: Upgrade Kotlin to 1.3.30 Upgrade coroutines to 1.2.0 Upgrade serialization to 0.11.0 Upgrade Ktor to 1.1.4 Upgrade Spring Boot to 2.1.4 --- .../pl/treksoft/kvision/remote/KVServiceManager.kt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl') diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index af185f19..d2b4f7ea 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -23,14 +23,11 @@ package pl.treksoft.kvision.remote import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import kotlinx.coroutines.CoroutineStart -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.ReceiveChannel import kotlinx.coroutines.channels.SendChannel -import kotlinx.coroutines.channels.filterNotNull -import kotlinx.coroutines.channels.map import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import org.slf4j.Logger @@ -420,16 +417,19 @@ actual open class KVServiceManager actual constructor(val serviceClass: WebSocketSessionHolder.webSocketSession = webSocketSession ctx.getBean(serviceClass.java) } - val requestChannel = incoming.map { - val jsonRpcRequest = getParameter(it) - if (jsonRpcRequest.params.size == 1) { - getParameter(jsonRpcRequest.params[0]) - } else { - null - } - }.filterNotNull() + val requestChannel = Channel() val responseChannel = Channel() coroutineScope { + launch { + for (p in incoming) { + val jsonRpcRequest = getParameter(p) + if (jsonRpcRequest.params.size == 1) { + val par = getParameter(jsonRpcRequest.params[0]) + requestChannel.send(par) + } + } + requestChannel.close() + } launch { for (p in responseChannel) { val text = mapper.writeValueAsString( -- cgit