data class CloseReason
Websocket close reason |
|
expect interface DefaultWebSocketSession : WebSocketSession
Default websocket session with ping-pong and timeout processing and built-in closeReason population |
|
class DefaultWebSocketSessionImpl : DefaultWebSocketSession, WebSocketSession
Default web socket session implementation that handles ping-pongs, close sequence and frame fragmentation |
|
sealed expect class Frame
A frame received or ready to be sent. It is not reusable and not thread-safe |
|
class FrameParser |
|
enum class FrameType
Frame types enum |
|
class RawWebSocket : WebSocketSession
Represents a RAW web socket session |
|
class Serializer |
|
class SimpleFrameCollector |
|
class WebSocketDeflateExtension : WebSocketExtension<Config>
Compress and decompress WebSocket frames to reduce amount of transferred bytes. |
|
interface WebSocketExtension<ConfigType : Any>
WebSocket extension instance. This instance is created for each WebSocket request, for every installed extension by WebSocketExtensionFactory. |
|
interface WebSocketExtensionFactory<ConfigType : Any, ExtensionType : WebSocketExtension<ConfigType>>
Factory that defines WebSocket extension. The factory is used in pair with WebSocketExtensionsConfig.install method to install WebSocket extension in client or server. |
|
class WebSocketExtensionHeader
Parsed |
|
class WebSocketExtensionsConfig
Extensions configuration for WebSocket client and server features. |
|
class WebSocketReader : CoroutineScope
Class that continuously reads a byteChannel and converts into Websocket Frame exposing them in incoming. |
|
expect interface WebSocketSession : CoroutineScope
Represents a web socket session between two peers |
|
class WebSocketWriter : CoroutineScope
Class that processes written outgoing Websocket Frame, serializes them and writes the bits into the writeChannel. |
annotation class ExperimentalWebSocketExtensionApi
WebSocket extensions API is experimental according to KTOR-688 To get more information about Ktor experimental guarantees consult with KTOR-1035. |
|
annotation class WebSocketInternalAPI
API marked with this annotation is internal and not intended to be used outside of ktor It is not recommended to use it as it may be changed in the future without notice or it may be too low-level so could damage your data. |
expect fun DefaultWebSocketSession(session: WebSocketSession, pingInterval: Long, timeoutMillis: Long): DefaultWebSocketSession
Create DefaultWebSocketSession from session. |
|
suspend fun WebSocketSession.close(reason: CloseReason = CloseReason(CloseReason.Codes.NORMAL, "")): Unit
Send a close frame with the specified reason. May suspend if outgoing channel is full. The specified reason could be ignored if there was already close frame sent (for example in reply to a peer close frame). It also may do nothing when a session or an outgoing channel is already closed due to any reason. suspend fun WebSocketSession.
Closes with reason depending on cause or normally if cause is |
|
suspend fun WebSocketSession.closeExceptionally(cause: Throwable): Unit
Closes session with normal or error close reason, depending on whether cause is cancellation or not. |
|
fun <T : WebSocketExtension<*>> WebSocketSession.extension(extension: WebSocketExtensionFactory<*, T>): T
Find the extensions using WebSocketExtensionFactory. |
|
fun <T : WebSocketExtension<*>> WebSocketSession.extensionOrNull(extension: WebSocketExtensionFactory<*, T>): T?
Search the extensions using WebSocketExtensionFactory. |
|
fun parseWebSocketExtensions(value: String): List<WebSocketExtensionHeader>
Parse |
|
fun Frame.readBytes(): ByteArray
Read binary content from a frame. For fragmented frames only returns this fragment. |
|
fun Close.readReason(): CloseReason?
Read close reason from close frame or null if no close reason provided |
|
fun Close. |
|
fun Text.readText(): String
Read text content from text frame. Shouldn't be used for fragmented frames: such frames need to be reassembled first |
|
suspend fun DefaultWebSocketSession.run(handler: suspend DefaultWebSocketSession.() -> Unit): Unit |
|
suspend fun WebSocketSession.send(content: String): Unit
Enqueues a text frame for sending with the specified content. suspend fun WebSocketSession.send(content: ByteArray): Unit
Enqueues a final binary frame for sending with the specified content. |
|
suspend fun RawWebSocket.start(handler: suspend WebSocketSession.() -> Unit): Unit |