+client.localIdentity

This commit is contained in:
Sergey Chernov 2024-11-22 09:18:07 +07:00
parent f2d8330ccc
commit 4098358233
2 changed files with 11 additions and 1 deletions

1
.gitignore vendored
View File

@ -44,3 +44,4 @@ out/
# More
.kotlin
/.idea/workspace.xml
/.gigaide/gigaide.properties

View File

@ -9,6 +9,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import net.sergeych.crypto2.SigningKey
import net.sergeych.crypto2.VerifyingKey
import net.sergeych.crypto2.VerifyingPublicKey
import net.sergeych.mp_logger.LogTag
import net.sergeych.mp_logger.Loggable
@ -60,6 +61,14 @@ class KiloClient<S>(
@Suppress("unused")
val connectedStateFlow = _state.asStateFlow()
/**
* The verifying, or public, key identifying client sessions. It could be used to
* restore environment on reconnection. This is what remote side, e.g. server, sees as
* [KiloScope.remoteIdentity].
*/
@Suppress("unused")
val localIdentity: VerifyingKey? = secretKey?.verifyingKey
private var deferredClient = CompletableDeferred<KiloClientConnection<S>>()
private val job =
@ -141,7 +150,7 @@ class KiloClient<S>(
* a key. Connection is established either with a properly authenticated key or no key at all.
*/
@Suppress("unused")
suspend fun remoteId(): VerifyingPublicKey? = deferredClient.await().remoteId()
suspend fun remoteIdentity(): VerifyingPublicKey? = deferredClient.await().remoteId()
companion object {
class Builder<S>() {