WebSocketClient

A web socket client.

The client is used to connect to the server and create a WebSocketConnection. Then, most of the interactions are done through the WebSocketConnection until it is closed.

The same client can be reused to start multiple sessions, unless specified otherwise by the implementation.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Whether this client supports sending custom headers in the handshake via the connect method.

Functions

Link copied to clipboard
abstract suspend fun connect(url: String, protocols: List<String> = emptyList(), headers: Map<String, String> = emptyMap()): WebSocketConnection

Opens a web socket connection to the given url and suspends until the connection is OPEN.

Link copied to clipboard
fun WebSocketClient.withAutoReconnect(maxAttempts: Int = DEFAULT_MAX_ATTEMPTS, delayStrategy: RetryDelayStrategy = DEFAULT_DELAY_STRATEGY): WebSocketClient

Returns a new WebSocketClient that automatically reconnects on web socket errors using this client.