SocketConnection

Reusable WebSocket connection. Constructed using SocketConnectionFactory.

Inheritors

Properties

Link copied to clipboard
abstract val state: <Error class: unknown class><SocketConnectionState>

State of the connection. Includes received messages.

Functions

Link copied to clipboard
abstract suspend 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
abstract suspend fun disconnect()

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

Link copied to clipboard
abstract suspend 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.