Skip to content

KtorWebSocketTransport

//fluxbase-kotlin/io.github.nimbleflux.fluxbase.realtime/KtorWebSocketTransport

[jvm]
class KtorWebSocketTransport(trustAllCertificates: Boolean = false) : WebSocketTransport

Ktor-backed WebSocketTransport — the production WebSocket implementation for JVM/Android.

Connects to Fluxbase’s /realtime endpoint via Ktor’s WebSocket client (OkHttp engine). The connection is established eagerly on an internal Dispatchers.IO scope when connect is called; inbound text frames are bridged onto the returned Flow, which RealtimeChannel collects. Outbound messages are sent via send once the session handshake completes (observable via isConnected).

The protocol itself (subscribe/heartbeat/postgres_changes/broadcast) lives in RealtimeChannel; this class is purely the transport seam — the same SPI tests fake with FakeWebSocketTransport.

KtorWebSocketTransport [jvm]
constructor(trustAllCertificates: Boolean = false)
Name Summary
isConnected [jvm]
@Volatile
open override var isConnected: Boolean
Whether the transport is currently connected.
Name Summary
close [jvm]
open override fun close()
Close the connection.
connect [jvm]
open override fun connect(url: String): Flow<String>
Connect to the given URL and return a flow of incoming JSON text messages.
send [jvm]
open suspend override fun send(text: String)
Send a text message.