UnboundedWsListenerFlowAdapter

An adapter similar to WebSocketListenerFlowAdapter, but with an unlimited buffer and non-suspending callback functions. This is useful for bridging implementations that do not support backpressure (like the browser WebSocket API).

This implementation does not support partial messages.

Constructors

Functions

Link copied to clipboard
fun onBinaryMessage(bytes: ByteArray): ChannelResult<Unit>

Sends a WebSocketFrame.Binary frame to the incomingFrames flow.

Link copied to clipboard
fun onClose(code: Int, reason: String?): ChannelResult<Unit>

Sends a WebSocketFrame.Close to the incomingFrames flow, and completes it normally.

Link copied to clipboard
fun onError(message: String)

Fails the incomingFrames flow with a WebSocketException with the given message.

fun onError(error: Throwable?)

Fails the incomingFrames flow with a WebSocketException with the given error as cause.

Link copied to clipboard
fun onPing(bytes: ByteArray): ChannelResult<Unit>

Sends a WebSocketFrame.Ping frame to the incomingFrames flow.

Link copied to clipboard
fun onPong(bytes: ByteArray): ChannelResult<Unit>

Sends a WebSocketFrame.Pong frame to the incomingFrames flow.

Link copied to clipboard
fun onTextMessage(text: String): ChannelResult<Unit>

Sends a WebSocketFrame.Text frame to the incomingFrames flow.

Properties

Link copied to clipboard

The channel of incoming web socket frames. This channel is closed when the web socket connection is closed