SfuSocketConnection

class SfuSocketConnection(apiKey: ApiKey, url: String, httpClient: OkHttpClient, networkStateProvider: NetworkStateProvider, scope: CoroutineScope = UserScope(ClientScope()), lifecycle: Lifecycle, tokenProvider: TokenProvider) : SocketListener<SfuDataEvent, JoinCallResponseEvent> , SocketActions<SfuDataRequest, SfuDataEvent, StreamWebSocketEvent.Error, SfuSocketState, SfuToken, <Error class: unknown class>>

Constructors

Link copied to clipboard
constructor(apiKey: ApiKey, url: String, httpClient: OkHttpClient, networkStateProvider: NetworkStateProvider, scope: CoroutineScope = UserScope(ClientScope()), lifecycle: Lifecycle, tokenProvider: TokenProvider)

Types

Link copied to clipboard
object Companion

Inherited properties

Link copied to clipboard

The callbacks are by default delivered on the main thread. Changing this property to false will deliver the callbacks on their originating threads.

Functions

Link copied to clipboard
open suspend override fun connect(connectData: <Error class: unknown class>)

Connect the user.

Link copied to clipboard
open override fun connectionId(): StateFlow<String?>

Get the connection id.

Link copied to clipboard
open suspend override fun disconnect()

Disconnect the socket.

Link copied to clipboard
open override fun errors(): MutableSharedFlow<StreamWebSocketEvent.Error>

Socket errors as Flow

Link copied to clipboard
open override fun events(): MutableSharedFlow<SfuDataEvent>

Socket events as Flow

Link copied to clipboard
open override fun onConnected(event: JoinCallResponseEvent)

Invoked when we receive the first ConnectedEventType in this connection.

Link copied to clipboard
open override fun onConnecting()

Invoked when the connection begins to establish and socket state changes to Connecting.

Link copied to clipboard
open override fun onCreated()

Called when the socket is created.

Link copied to clipboard
open override fun onDisconnected(cause: DisconnectCause)

Invoked when the web socket connection is disconnected.

Link copied to clipboard
open override fun onError(error: StreamWebSocketEvent.Error)

Invoked when there is any error in this web socket connection.

Link copied to clipboard
open override fun onEvent(event: SfuDataEvent)

Invoked when we receive any successful event.

Link copied to clipboard
open suspend override fun reconnect(data: <Error class: unknown class>, force: Boolean)

Reconnect the user to the socket.

Link copied to clipboard
open override fun sendData(data: String)

Send raw data to the socket. If you already have a parsed event that can be sent.

Link copied to clipboard
open suspend override fun sendEvent(event: SfuDataRequest): Boolean

Send event to the socket.

Link copied to clipboard
open override fun state(): StateFlow<SfuSocketState>

State of the socket as StateFlow

Link copied to clipboard
open override fun updateToken(token: SfuToken)

Update the token from the outside.

Link copied to clipboard
open override fun whenConnected(connectionTimeout: Long, connected: suspend (connectionId: String) -> Unit)

When connected to the socket.