diff options
-rw-r--r-- | kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt | 3 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt | 13 |
2 files changed, 7 insertions, 9 deletions
diff --git a/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt b/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt index 7b339621..6c1b47e7 100644 --- a/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt +++ b/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt @@ -26,6 +26,7 @@ import kotlinx.coroutines.experimental.Deferred import kotlinx.coroutines.experimental.runBlocking import org.jooby.Response import org.jooby.Status +import org.slf4j.Logger import org.slf4j.LoggerFactory /** @@ -35,7 +36,7 @@ import org.slf4j.LoggerFactory actual open class ServiceManager<out T> actual constructor(val service: T?) { companion object { - val LOG = LoggerFactory.getLogger(ServiceManager::class.java.name) + val LOG: Logger = LoggerFactory.getLogger(ServiceManager::class.java.name) } protected val routes: MutableList<JoobyServer.() -> Unit> = mutableListOf() diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt index 2f85a51f..7d9f4b05 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt @@ -59,14 +59,11 @@ open class CallAgent { this.method = method.name this.success = { data: dynamic, _: Any, _: Any -> - if (data.id != jsonRpcRequest.id) { - reject(Exception("Invalid response ID")) - } else if (data.error != null) { - reject(Exception(data.error.toString())) - } else if (data.result != null) { - resolve(data.result) - } else { - reject(Exception("Invalid response")) + when { + data.id != jsonRpcRequest.id -> reject(Exception("Invalid response ID")) + data.error != null -> reject(Exception(data.error.toString())) + data.result != null -> resolve(data.result) + else -> reject(Exception("Invalid response")) } } this.error = |