// val connectionId: String // Postbox identifier.
// A list of received messages
private var relayMessagesReceived = mutableListOf<RelayMessage>()
val subscriber = object : DIRelayEventSubscriber {
override fun messageIncoming(message: RelayMessage) {
// Handle incoming message.
relayMessagesReceived.add(message)
override fun postBoxDeleted(update: PostboxDeletionResult) {
// Handle postbox deleted update.
override fun connectionStatusChanged(state: DIRelayEventSubscriber.ConnectionState) {
// Handle changes in the state of the subscription connection
withContext(Dispatchers.IO) {
relayClient.subscribeToRelayEvents(
} catch (e: SudoDIRelayClient.DIRelayException) {
// Handle/notify user of exception