spring-framework / org.springframework.web.socket.messaging / SubProtocolHandler

SubProtocolHandler

interface SubProtocolHandler

A contract for handling WebSocket messages as part of a higher level protocol, referred to as "sub-protocol" in the WebSocket RFC specification. Handles both WebSocketMessages from a client as well as Messages to a client.

Implementations of this interface can be configured on a SubProtocolWebSocketHandler which selects a sub-protocol handler to delegate messages to based on the sub-protocol requested by the client through the Sec-WebSocket-Protocol request header.

Author
Andy Wilkinson

Author
Rossen Stoyanchev

Since
4.0

Functions

afterSessionEnded

abstract fun afterSessionEnded(session: WebSocketSession, closeStatus: CloseStatus, outputChannel: MessageChannel): Unit

Invoked after a WebSocketSession has ended.

afterSessionStarted

abstract fun afterSessionStarted(session: WebSocketSession, outputChannel: MessageChannel): Unit

Invoked after a WebSocketSession has started.

getSupportedProtocols

abstract fun getSupportedProtocols(): MutableList<String>

Return the list of sub-protocols supported by this handler (never null).

handleMessageFromClient

abstract fun handleMessageFromClient(session: WebSocketSession, message: WebSocketMessage<*>, outputChannel: MessageChannel): Unit

Handle the given WebSocketMessage received from a client.

handleMessageToClient

abstract fun handleMessageToClient(session: WebSocketSession, message: Message<*>): Unit

Handle the given Message to the client associated with the given WebSocket session.

resolveSessionId

abstract fun resolveSessionId(message: Message<*>): String

Resolve the session id from the given message or return null.