class WebSockets : CoroutineScope
WebSockets support feature. It is required to be installed first before binding any websocket endpoints
install(WebSockets)
install(Routing) {
webSocket("/ws") {
incoming.consumeForEach { ... }
}
}
pingIntervalMillis
- duration between pings or null
to disable pings.
timeoutMillis
- write/ping timeout after that a connection will be closed.
maxFrameSize
- maximum frame that could be received or sent.
masking
- whether masking need to be enabled (useful for security).
extensionsConfig
- is configuration for WebSocket extensions.
companion object Feature : ApplicationFeature<Application, WebSocketOptions, WebSockets>
Feature installation object. |
|
class WebSocketOptions
Websockets configuration options |
WebSockets(pingIntervalMillis: Long, timeoutMillis: Long, maxFrameSize: Long, masking: Boolean) WebSockets(pingIntervalMillis: Long, timeoutMillis: Long, maxFrameSize: Long, masking: Boolean, extensionsConfig: WebSocketExtensionsConfig)
WebSockets support feature. It is required to be installed first before binding any websocket endpoints |
val coroutineContext: <ERROR CLASS> |
|
val extensionsConfig: WebSocketExtensionsConfig
is configuration for WebSocket extensions. |
|
val masking: Boolean
whether masking need to be enabled (useful for security). |
|
val maxFrameSize: Long
maximum frame that could be received or sent. |
|
val pingIntervalMillis: Long
duration between pings or |
|
val timeoutMillis: Long
write/ping timeout after that a connection will be closed. |
val EXTENSIONS_KEY: AttributeKey<List<WebSocketExtension<*>>>
Key for saving configured WebSocket extensions for the specific call. |
|
val key: AttributeKey<WebSockets> |
fun install(pipeline: Application, configure: WebSocketOptions.() -> Unit): WebSockets |
val WebSockets.pingInterval: Duration? |
|
val WebSockets.timeout: Duration |
fun CoroutineScope.pinger(outgoing: SendChannel<Frame>, period: Duration, timeout: Duration, pool: ObjectPool<ByteBuffer> = KtorDefaultPool): SendChannel<Pong>
Launch pinger coroutine on CoroutineScope that is sending ping every specified period to outgoing channel, waiting for and verifying client's pong frames. It is also handling timeout and sending timeout close frame |
|
fun CoroutineScope.pinger(outgoing: SendChannel<Frame>, period: <ERROR CLASS>, timeout: <ERROR CLASS>, pool: ObjectPool<ByteBuffer> = KtorDefaultPool): SendChannel<Pong>
Launch pinger coroutine on CoroutineScope that is sending ping every specified period to outgoing channel, waiting for and verifying client's pong frames. It is also handling timeout and sending timeout close frame |