aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-server-ktor/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-04-16 18:07:11 +0200
committerRobert Jaros <rjaros@finn.pl>2019-04-16 18:07:11 +0200
commit856d753c7f335dacd9cc4daf666a152378886200 (patch)
tree549c667ba6047a0405bd112d8e91be117c798012 /kvision-modules/kvision-server-ktor/src
parent2382d82d5aaed8e6519da9e82d771ee94007b2cd (diff)
downloadkvision-856d753c7f335dacd9cc4daf666a152378886200.tar.gz
kvision-856d753c7f335dacd9cc4daf666a152378886200.tar.bz2
kvision-856d753c7f335dacd9cc4daf666a152378886200.zip
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
Diffstat (limited to 'kvision-modules/kvision-server-ktor/src')
-rw-r--r--kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt25
1 files changed, 13 insertions, 12 deletions
diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index 11771cfa..3c5391b6 100644
--- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -44,8 +44,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
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
@@ -378,20 +376,23 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
webSocketRequests["/kvws/$routeDef"] = {
val wsInjector = call.injector.createChildInjector(WsSessionModule(this))
val service = wsInjector.getInstance(serviceClass.java)
- val requestChannel = incoming.map {
- (it as? Frame.Text)?.readText()?.let { text ->
- val jsonRpcRequest = getParameter<JsonRpcRequest>(text)
- if (jsonRpcRequest.params.size == 1) {
- getParameter<PAR1>(jsonRpcRequest.params[0])
- } else {
- null
- }
- }
- }.filterNotNull()
+ val requestChannel = Channel<PAR1>()
val responseChannel = Channel<PAR2>()
val session = this
coroutineScope {
launch {
+ for (p in incoming) {
+ (p as? Frame.Text)?.readText()?.let { text ->
+ val jsonRpcRequest = getParameter<JsonRpcRequest>(text)
+ if (jsonRpcRequest.params.size == 1) {
+ val par = getParameter<PAR1>(jsonRpcRequest.params[0])
+ requestChannel.send(par)
+ }
+ }
+ }
+ requestChannel.close()
+ }
+ launch {
for (p in responseChannel) {
val text = mapper.writeValueAsString(
JsonRpcResponse(