Package org.hildan.krossbow.websocket

Types

Link copied to clipboard
class 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).

Link copied to clipboard
interface WebSocketClient

A web socket client.

Link copied to clipboard
object WebSocketCloseCodes

Web socket close codes as defined in the WebSocket Protocol specification.

Link copied to clipboard
interface WebSocketConnection

Represents a web socket connection to another endpoint.

Link copied to clipboard
class WebSocketConnectionClosedException(    val url: String,     val code: Int,     val reason: String?) : WebSocketConnectionException

An exception thrown when the server closed the connection unexpectedly during the handshake.

Link copied to clipboard
open class WebSocketConnectionException(    val url: String,     val httpStatusCode: Int? = null,     message: String = "Couldn't connect to web socket at $url" + statusInfo(httpStatusCode),     cause: Throwable? = null) : WebSocketException

An exception thrown when something went wrong during the web socket connection.

Link copied to clipboard
interface WebSocketConnectionWithPing : WebSocketConnection
Link copied to clipboard
interface WebSocketConnectionWithPingPong : WebSocketConnectionWithPing
Link copied to clipboard
open class WebSocketException(message: String, cause: Throwable? = null) : Exception

An exception thrown when something went wrong at web socket level.

Link copied to clipboard
sealed class WebSocketFrame

A web socket frame.

Link copied to clipboard
class WebSocketListenerFlowAdapter(bufferSize: Int = Channel.BUFFERED, onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND)

Adapter between listener calls and a web socket "incoming" frames flow. This is to make it easier to bridge listener-based APIs with the flow-based API of Krossbow. Methods of this listener never fail, but can send failure through the frames channel to the consumers.

Functions

Link copied to clipboard
fun String.truncateToCloseFrameReasonLength(): String

Truncates this string to 123 bytes (CLOSE_REASON_MAX_LENGTH_BYTES), for it to be suitable as web socket close reason.

Link copied to clipboard
fun String.truncateUtf8BytesLengthTo(maxLength: Int): String

Returns the biggest prefix of this string that can be represented with at most maxLength UTF-8 bytes.

Properties

Link copied to clipboard
const val CLOSE_REASON_MAX_LENGTH_BYTES: Int = 123

The maximum number of UTF-8 bytes allowed by the web socket protocol for the "reason" in close frames. This limit is defined in section 5.5 of the RFC-6455.