MessageSubscriber

Subscribers implement this interface to receive notifications of newly created Messages

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
}

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.

Link copied to clipboard
abstract fun messageCreated(message: Message)

Notifies the subscriber of a new Message