Subscriber

interface Subscriber

Subscribers implement this interface to receive notifications of incoming RelayMessages and postbox deletion updates.

Samples

import android.content.Context
import com.sudoplatform.sudodirelay.BaseTests
import com.sudoplatform.sudodirelay.SudoDIRelayClient
import com.sudoplatform.sudodirelay.subscription.MessageSubscriber
import com.sudoplatform.sudodirelay.subscription.Subscriber
import com.sudoplatform.sudodirelay.types.Message
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.mock
import org.robolectric.RobolectricTestRunner
fun main() { 
   //sampleStart 
   val subscriber = object : MessageSubscriber {
    override fun messageCreated(message: Message) {
        println("new message incoming! $message")
    }

    override fun connectionStatusChanged(state: Subscriber.ConnectionState) {
        println("connection has changed to state: $state")
    }
} 
   //sampleEnd
}

Inheritors

Types

Link copied to clipboard

Connection state of the subscription.

Functions

Link copied to clipboard

Notifies the subscriber that the subscription connection state has changed. The subscriber won't be notified of changes until the connection status changes to ConnectionState.CONNECTED. The subscriber will stop receiving notifications when the connection state changes to ConnectionState.DISCONNECTED.