Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions java/self-demo/src/main/kotlin/com/joinself/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import com.joinself.selfsdk.keypair.signing.PublicKey
import com.joinself.selfsdk.message.*
import com.joinself.selfsdk.platform.Attestation
import com.joinself.selfsdk.time.Timestamp
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.util.concurrent.Semaphore
import kotlin.coroutines.suspendCoroutine
Expand Down Expand Up @@ -43,7 +47,7 @@ fun main() {
val signal = Semaphore(1)
signal.acquire()

var discoveryRequestId: String = ""
val coroutineScope = CoroutineScope(Dispatchers.IO)

val sandbox = true
val rpcAddress = if (sandbox) Target.PRODUCTION_SANDBOX.rpcEndpoint() else Target.PRODUCTION.rpcEndpoint()
Expand Down Expand Up @@ -75,13 +79,18 @@ fun main() {
println("KMP commited")
},
onKeyPackage = { keyPackage: KeyPackage ->
println("KMP keypackage")
println("KMP keyPackage")
account.connectionEstablish(asAddress = keyPackage.toAddress(), keyPackage = keyPackage.keyPackage(),
onCompletion = {status: SelfStatus, gAddress: PublicKey ->
println("connection establish status:${status.name()} - group:${gAddress.encodeHex()}")
responderAddress = keyPackage.fromAddress()
groupAddress = gAddress
signal.release()

coroutineScope.launch {
delay(1000)
generateQrCode(account)
}
}
)
},
Expand Down Expand Up @@ -109,10 +118,6 @@ fun main() {
val responseTo = discoveryResponse.responseTo().toHexString()
println("received response to discovery request from:${message.fromAddress().encodeHex()} - requestId:${responseTo} - messageId:${message.id().toHexString()}")

if (responseTo != discoveryRequestId) {
println("received response to unknown request requestId:$responseTo")
}

signal.release()

generateQrCode(account)
Expand Down