WebSocketConnection

Represents a web socket connection to another endpoint.

Implementations must be safe to call concurrently.

Inheritors

Properties

Link copied to clipboard
abstract val canSend: Boolean

If false, sending frames should not be attempted and will likely throw an exception. If true, sending frames will likely succeed. However, no guarantees can be made because there could be a race condition between WS closure and a "send" call.

Link copied to clipboard
open val host: String

The host to which this web socket is connected.

Link copied to clipboard

The single-consumer hot flow of incoming web socket frames.

Link copied to clipboard
abstract val protocol: String?

The web socket subprotocol spoken over this WebSocketConnection, or null is no specific protocol was agreed upon during the handshake. This can happen either because the client did not request any protocol, or because none of the requested protocols were accepted by the server.

Link copied to clipboard
abstract val url: String

The URL that was used to connect this web socket.

Functions

Link copied to clipboard
abstract suspend fun close(code: Int = WebSocketCloseCodes.NORMAL_CLOSURE, reason: String? = null)

Sends a web socket close frame with the given code and reason, and closes the connection.

Link copied to clipboard
abstract suspend fun sendBinary(frameData: ByteString)

Sends a web socket binary frame.

Link copied to clipboard
abstract suspend fun sendText(frameText: String)

Sends a web socket text frame.