OkHttpSocketConnection

class OkHttpSocketConnection(clientOptions: HttpClientOptions, scope: CoroutineScope) : SocketConnection

Constructors

Link copied to clipboard
constructor(clientOptions: HttpClientOptions, scope: CoroutineScope)

Properties

Link copied to clipboard
open override val state: StateFlow<SocketConnectionState>

State of the connection. Includes received messages.

Functions

Link copied to clipboard
open suspend override fun connect(url: String, authorization: String): Boolean

Connect to url. If there is an existing connection it should be automatically disconnected. After a connection is initialized the state should be updated until disconnect is called or the connection is closed by other means (server closed, network issues, new connect call etc.).

Link copied to clipboard
open suspend override fun disconnect()

Disconnect the WebSocket. Will do nothing when there is no connection.

Link copied to clipboard
open suspend override fun send(message: String): Boolean

Send a message to this connection. Messages may be added to an internal queue and be slightly delayed. The implementation must enqueue messages send while still connecting.