The SDK exposes the capabilities of the active transport as a set of SurrealFeature values, and the lifecycle of the connection as a stream of SurrealConnectionEvent.
Source: surrealdb.kotlin
import com.surrealdb.kotlin.SurrealFeature
import com.surrealdb.kotlin.engine.SurrealConnectionEvent SurrealFeature
An enum of the features a transport may support. Inspect the active set via the features property, or check a single feature with .supports().
Value | Available on |
|---|---|
LiveQueries | WebSocket |
Transactions | WebSocket |
Sessions | WebSocket |
RefreshTokens | WebSocket |
ExportImport | WebSocket, HTTP |
SurrealML | WebSocket, HTTP |
if (client.supports(SurrealFeature.LiveQueries)) {
val subscription = client.live("person")
} SurrealConnectionEvent
A sealed class emitted on the client's connectionEvents SharedFlow.
Variant | Payload | Description |
|---|---|---|
Connecting | — | A connection attempt has started. |
Connected | — | The connection is established. |
Disconnected | — | The connection has dropped. |
Reconnecting | attempt: Int, delayMillis: Long | A reconnect is scheduled. |
Error | cause: Throwable | A connection error occurred. |
client.connectionEvents.collect { event ->
when (event) {
is SurrealConnectionEvent.Connected -> println("connected")
is SurrealConnectionEvent.Reconnecting -> println("attempt ${event.attempt}")
is SurrealConnectionEvent.Error -> println("error: ${event.cause.message}")
else -> {}
}
}