waitForConnection

suspend fun List<MdocTransport>.waitForConnection(eSenderKeyBytes: ByteString): MdocTransport

A helper for waiting until someone connects to a transport.

The list of transports must contain transports that are all in the state MdocTransport.State.ADVERTISING or MdocTransport.State.IDLE.

The first connection which a remote peer connects to is returned and the other ones are closed.

Return

the MdocTransport a remote peer connected to, will be in MdocTransport.State.CONNECTED state.

Parameters

eSenderKeyBytes

The exact wire-encoded EDeviceKeyBytes if using forward engagement or EReaderKeyBytes if using reverse engagement, including the #6.24 CBOR tag.

Throws

if the list contains duplicate transports.

if no transport connected or if a transport is not in MdocTransport.State.ADVERTISING or MdocTransport.State.IDLE state.