small fix in client, more docs
This commit is contained in:
1 parent
192f7e135f
commit
745eb9ccdf
7 files changed
+66
-16
No files matched your search
@@ -48,7 +48,7 @@ class KiloClient<S>(
|
||||
val client = KiloClientConnection(localInterface, kc,secretKey)
|
||||
deferredClient.complete(client)
|
||||
client.run {
|
||||
_state.value = false
|
||||
_state.value = it
|
||||
}
|
||||
debug { "client run finished" }
|
||||
} catch (_: RemoteInterface.ClosedException) {
|
||||
|
||||
@@ -7,7 +7,13 @@ import net.sergeych.utools.unpack
|
||||
|
||||
private var L1IdCounter = 0
|
||||
|
||||
// todo: We don't need it deferred here
|
||||
/**
|
||||
* Represents a remote interface for interacting with a Kiloparsec service.
|
||||
*
|
||||
* @param S the scope type of the Kiloparsec service which will be used to call local functions remotely
|
||||
* @property deferredParams a [CompletableDeferred] that resolves to the parameters required for making remote calls
|
||||
* @property clientInterface a [LocalInterface] used to communicate with the local client
|
||||
*/
|
||||
class KiloRemoteInterface<S>(
|
||||
private val deferredParams: CompletableDeferred<KiloParams<S>>,
|
||||
private val clientInterface: LocalInterface<KiloScope<S>>,
|
||||
|
||||
@@ -79,8 +79,8 @@ fun <S>websocketClient(
|
||||
}
|
||||
val device = ProxyDevice(input,output) {
|
||||
input.close()
|
||||
// we need to explicitly close the coroutine job or it can hang active
|
||||
// forever and leak resources:
|
||||
// we need to explicitly close the coroutine job, or it can hang for a long time
|
||||
// leaking resources.
|
||||
job.cancel()
|
||||
}
|
||||
KiloConnectionData(device, sessionMaker())
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.sergeych.mp_logger.Log
|
||||
import java.net.InetAddress
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ClientTest {
|
||||
|
||||
@@ -78,6 +79,7 @@ class ClientTest {
|
||||
val client = websocketClient<Unit>("ws://localhost:8080/kp")
|
||||
println(1)
|
||||
assertEquals(true, client.call(cmdCheckConnected))
|
||||
assertTrue { client.state.value }
|
||||
println(2)
|
||||
assertEquals("not set", client.call(cmdGetFoo))
|
||||
println(3)
|
||||
|
||||
Reference in new issue
Block a user