class AsyncWebSocketSession
source · line 11public class AsyncWebSocketSession internal constructor(
private val state: WsState
) : AsyncCloseable
- Supertype
AsyncCloseable
A structured WebSocket session over an already-upgraded transport. Background tasks handle control frames and bounded message backpressure; serialize message operations in each direction.
function sendText
source · line 93public suspend fun sendText(text: String, compress: Boolean = true): Unit
Sends one complete UTF-8 text message with optional negotiated compression.
parameter compress
source · line 93compress: Boolean = true
parameter text
source · line 93text: String
property role
source · line 38public val role: HttpRole
get: public read-only
The local client/server role controlling masking and negotiated settings.
getter get
source · line 38get(): HttpRole
function close
source · line 141public override suspend fun close(): Unit
- Overrides
close
Performs local closure, cancelling owned I/O and waiting for native borrows and cleanup. Repeated close is supported, including cleanup from an already-cancelled caller.
function awaitClosed
source · line 134public suspend fun awaitClosed(): Unit
Waits for session cleanup to complete.
function ping
source · line 115public suspend fun ping(payload: List<Byte> = emptyList<Byte>()): Unit
Sends a Ping and waits for its matching Pong.
parameter payload
source · line 115payload: List<Byte> = emptyList<Byte>()
property isClosed
source · line 50public val isClosed: Boolean
get: public read-only
Whether owned session cleanup has completed.
getter get
source · line 50get(): Boolean
property deflate
source · line 42public val deflate: WebSocketDeflateNegotiation?
get: public read-only
The actual permessage-deflate negotiation, if compression was negotiated.
getter get
source · line 42get(): Option<WebSocketDeflateNegotiation>
function shutdownGracefully
source · line 128public suspend fun shutdownGracefully(value: WebSocketClose = WebSocketClose(Some(1000U))): WebSocketClose
Sends Close and waits for peer Close, transport flush, and cleanup within the configured deadline.
parameter value
source · line 129value: WebSocketClose = WebSocketClose(Some(1000U))
function pong
source · line 121public suspend fun pong(payload: List<Byte> = emptyList<Byte>()): Unit
Sends an unsolicited Pong without waiting for a reply.
parameter payload
source · line 121payload: List<Byte> = emptyList<Byte>()
function beginMessage
source · line 68public suspend fun beginMessage(type: WebSocketMessageType, compress: Boolean = true): WebSocketMessageWriter
Begins one streamed outgoing message. Compression can be disabled for this message even when negotiated; finish the returned writer before another message.
parameter type
source · line 69type: WebSocketMessageType
parameter compress
source · line 70compress: Boolean = true
function sendBinary
source · line 99public suspend fun sendBinary(bytes: List<Byte>, compress: Boolean = true): Unit
Sends one complete binary message with optional negotiated compression.
parameter bytes
source · line 99bytes: List<Byte>
parameter compress
source · line 99compress: Boolean = true
property sentClose
source · line 58public val sentClose: WebSocketClose?
get: public read-only
The close frame sent by this session, when available.
getter get
source · line 58get(): Option<WebSocketClose>
property peerClose
source · line 54public val peerClose: WebSocketClose?
get: public read-only
The received peer close frame, when available.
getter get
source · line 54get(): Option<WebSocketClose>
function receive
source · line 89public suspend fun receive(): WebSocketMessage?
Waits for the next message or returns None at normal session end. Complete the current message before requesting another.
function send
source · line 105public suspend fun send(type: WebSocketMessageType, source: AsyncByteSource, compress: Boolean = true): Unit
Streams one complete message from a borrowed source; the source is not closed by this call.
parameter compress
source · line 108compress: Boolean = true
parameter source
source · line 107source: AsyncByteSource
parameter type
source · line 106type: WebSocketMessageType
property failure
source · line 62public val failure: Throwable?
get: public read-only
The retained terminal session failure, or None when closure has no recorded failure.
getter get
source · line 62get(): Option<Throwable>