From 9374d0df9c462493e9cb91c846e4f820b3325f7b Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 10 Apr 2019 18:24:14 +0200 Subject: Websockets support for Spring Boot and Jooby. --- .../src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt | 7 ++++--- .../src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'kvision-modules/kvision-remote/src/main/kotlin/pl') diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt index 9c6f8274..d3331b2a 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt @@ -21,6 +21,7 @@ */ package pl.treksoft.kvision.remote +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job import kotlinx.coroutines.asDeferred import kotlinx.coroutines.channels.Channel @@ -41,7 +42,7 @@ import kotlin.js.JSON as NativeJSON * Client side agent for JSON-RPC remote calls. */ @Suppress("LargeClass", "TooManyFunctions") -@UseExperimental(ImplicitReflectionSerializer::class) +@UseExperimental(ImplicitReflectionSerializer::class, ExperimentalCoroutinesApi::class) open class KVRemoteAgent(val serviceManager: KVServiceManager) : RemoteAgent { val callAgent = CallAgent() @@ -407,7 +408,7 @@ open class KVRemoteAgent(val serviceManager: KVServiceManager) : Rem responseJob = launch { while (true) { val str = socket.receiveOrNull() ?: break - val data = kotlin.js.JSON.parse(str).result + val data = kotlin.js.JSON.parse(str).result ?: "" val par2 = try { @Suppress("UNCHECKED_CAST") deserialize(data, PAR2::class.js.name) @@ -477,7 +478,7 @@ open class KVRemoteAgent(val serviceManager: KVServiceManager) : Rem responseJob = launch { while (true) { val str = socket.receiveOrNull() ?: break - val data = kotlin.js.JSON.parse(str).result + val data = kotlin.js.JSON.parse(str).result ?: "" val par2 = try { deserializeList(data, PAR2::class.js.name) } catch (t: NotStandardTypeException) { diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 0cf72f76..7db690b2 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -149,7 +149,7 @@ actual open class KVServiceManager actual constructor(serviceClass: KCl route: String? ) { val routeDef = "route${this::class.simpleName}${counter++}" - calls[function.toString().replace("\\s".toRegex(), "")] = Pair("/kv/$routeDef", HttpMethod.POST) + calls[function.toString().replace("\\s".toRegex(), "")] = Pair("/kvws/$routeDef", HttpMethod.POST) } /** -- cgit