SeuraaEdge
v1
Docs/SDKs
SDKs

Connect Android and JVM applications with the Kotlin client.

Kotlin Client SDK

The Kotlin client connects Android and JVM applications to Seuraa Edge.

Installation

The SDK supports Java 11 and Android API 21 or newer. Use the SDK version supplied with your Seuraa account.

kotlin
implementation("app.seuraa:edge-kotlin:VERSION")

Client

kotlin
import app.seuraa.edge.Client
import app.seuraa.edge.ClientOptions

val edge = Client(
    ClientOptions(
        appKey = "app-key",
        authEndpoint = "https://api.example.com/seuraa/token",
    ),
)

The authentication endpoint receives the app key and channel name and returns a short-lived channel token.

Use TokenProvider instead when the application needs custom authentication headers or token-fetching behavior.

Subscribe

kotlin
@Serializable
data class Notification(val title: String)

val channel = edge.channel("private:user-123")

val subscription = channel.subscribe<Notification>("notification.created") { event ->
    println(event.data.title)
}

Closing subscription removes only that event handler. Call channel.unsubscribe() to leave the channel.

Publish

kotlin
val result = channel.publish(
    "typing.started",
    mapOf("documentId" to "document-123"),
)

Publishing is a suspending operation because the SDK may refresh the channel token.

Connection Status

kotlin
lifecycleScope.launch {
    edge.status.collect { state ->
        println(state.status)
    }
}

The client reconnects automatically and resumes active channels using their latest event cursors.

Presence And Errors

kotlin
channel.onRawEvent { event ->
    when (event) {
        is PresenceUpdated -> println(event.presence)
        is ServerError -> println(event.code.value)
        else -> Unit
    }
}

Call edge.close() when the client is no longer needed.