WebSocketUpgrade

class WebSocketUpgrade(call: ApplicationCall, protocol: String?, installExtensions: Boolean, handle: suspend WebSocketSession.() -> Unit) : OutgoingContent.ProtocolUpgrade

An OutgoingContent response object that could be used to respond(): it will cause application engine to perform HTTP upgrade and start websocket RAW session.

Please note that you generally shouldn't use this object directly but use WebSockets feature with routing builders webSocket instead.

handle function is applied to a session and as far as it is a RAW session, you should handle all low-level frames yourself and deal with ping/pongs, timeouts, close frames, frame fragmentation and so on.

Parameters

call

that is starting web socket session

protocol

web socket negotiated protocol name (optional)

installExtensions

specifies if WebSocket extensions should be installed in current session.

handle

function that is started once HTTP upgrade complete and the session will end once this function exit

Constructors

Link copied to clipboard
fun WebSocketUpgrade(call: ApplicationCall, protocol: String? = null, handle: suspend WebSocketSession.() -> Unit)

An OutgoingContent response object that could be used to respond(): it will cause application engine to perform HTTP upgrade and start websocket RAW session.

Link copied to clipboard
fun WebSocketUpgrade(call: ApplicationCall, protocol: String? = null, installExtensions: Boolean = false, handle: suspend WebSocketSession.() -> Unit)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open fun <T : Any> getProperty(key: AttributeKey<T>): T?
Link copied to clipboard
open fun <T : Any> setProperty(key: AttributeKey<T>, value: T?)
Link copied to clipboard
open suspend override fun upgrade(input: ByteReadChannel, output: ByteWriteChannel, engineContext: CoroutineContext, userContext: CoroutineContext): Job

Properties

Link copied to clipboard
val call: ApplicationCall
Link copied to clipboard
open val contentLength: Long?
Link copied to clipboard
open val contentType: ContentType?
Link copied to clipboard
val handle: suspend WebSocketSession.() -> Unit
Link copied to clipboard
open override val headers: Headers
Link copied to clipboard
val protocol: String? = null
Link copied to clipboard
override val status: HttpStatusCode?