WebSocketExtension

interface WebSocketExtension<ConfigType : Any>

WebSocket extension instance. This instance is created for each WebSocket request, for every installed extension by WebSocketExtensionFactory.

Properties

factory

Reference to the WebSocketExtensionFactory, which produced this extension.

protocols

abstract val protocols: List<WebSocketExtensionHeader>

List of WebSocket extension protocols which will be sent by client in headers. They are required to inform server that client wants to negotiate current extension.

Functions

clientNegotiation

abstract fun clientNegotiation(
    negotiatedProtocols: List<WebSocketExtensionHeader>
): Boolean

This method is called only for a client, when it receives the WebSocket upgrade response.

processIncomingFrame

abstract fun processIncomingFrame(frame: Frame): Frame

This method is called on each incoming frame before handling it in WebSocket session.

processOutgoingFrame

abstract fun processOutgoingFrame(frame: Frame): Frame

This method is called on each outgoing frame and handle it before sending.

serverNegotiation

abstract fun serverNegotiation(
    requestedProtocols: List<WebSocketExtensionHeader>
): List<WebSocketExtensionHeader>

This method is called only for a server, when it receives websocket session.

Inheritors

WebSocketDeflateExtension

class WebSocketDeflateExtension : WebSocketExtension<Config>

Compress and decompress WebSocket frames to reduce amount of transferred bytes.