webSocket

fun Route.webSocket(
    protocol: String? = null,
    handler: suspend DefaultWebSocketServerSession.() -> Unit
): Unit

Bind websocket at the current route optionally checking for websocket protocol (ignored if null) Requires WebSockets feature to be installed first

DefaultWebSocketSession.incoming will never contain any control frames and no fragmented frames could be found. Default websocket implementation is handling ping/pongs, timeouts, close frames and reassembling fragmented frames

When a websocket session is created, a handler lambda will be called with websocket session instance on receiver. Once handler function returns, the websocket termination sequence will be scheduled so you shouldn’t use DefaultWebSocketSession anymore. However websocket could live for a while until close sequence completed or a timeout exceeds

fun Route.webSocket(
    path: String,
    protocol: String? = null,
    handler: suspend DefaultWebSocketServerSession.() -> Unit
): Unit

Bind websocket at the current route + path optionally checking for websocket protocol (ignored if null) Requires WebSockets feature to be installed first

DefaultWebSocketSession.incoming will never contain any control frames and no fragmented frames could be found. Default websocket implementation is handling ping/pongs, timeouts, close frames and reassembling fragmented frames

When a websocket session is created, a handler lambda will be called with websocket session instance on receiver. Once handler function returns, the websocket termination sequence will be scheduled so you shouldn’t use DefaultWebSocketSession anymore. However websocket could live for a while until close sequence completed or a timeout exceeds