Connections
Creating a Connection
Parsing the invitation
// The url commonly comes from the result of scanning a QR code.
val invitation = OutOfBandInvitationMessage.fromUrl(url)
// Or if you have the message in json already
val invitation = OutOfBandInvitationMessage.fromJsonString(str)// parses the URL to a json string
const invitation: string = agent.outOfBand.parseInvitation(invitationUrl)Receiving and waiting for a completed connection
// Completed connection status may or may not be done after this call
val records = agent.outOfBand.receiveInvitation(invitation)
// Waits for the record to be in the completed state
agent.events.getDidExchangeEvents?.events?.first { event ->
if (records.didExchangeRecord.id != event.didExchangeRecord.id) {
event.didExchangeRecord.state == DidExchangeState.Completed
}
}// Takes the json formatted string for the invitation
const records = await agent.outOfBand.receiveInvitation(invitation)
const removeListener = agent?.events.registerDidExchangeHandler((event) => {
if (event.didExchangeRecord.id === records.didExchangeRecord.id && event.didExchangeRecord.isReady) {
console.log("Connection complete")
removeListener()
}
})Manually accepting a connection (autoAcceptConnection = false)
Retrieving and using the didExchange records
Removing a connection
Last updated
Was this helpful?