spring-framework / org.springframework.web.socket.sockjs.transport.handler / SockJsWebSocketHandler

SockJsWebSocketHandler

open class SockJsWebSocketHandler : TextWebSocketHandler, SubProtocolCapable

An implementation of WebSocketHandler that adds SockJS messages frames, sends SockJS heartbeat messages, and delegates lifecycle events and messages to a target WebSocketHandler.

Methods in this class allow exceptions from the wrapped WebSocketHandler to propagate. However, any exceptions resulting from SockJS message handling (e.g. while sending SockJS frames or heartbeat messages) are caught and treated as transport errors, i.e. routed to the handleTransportError method of the wrapped handler and the session closed.

Author
Rossen Stoyanchev

Since
4.0

Constructors

<init>

SockJsWebSocketHandler(serviceConfig: SockJsServiceConfig, webSocketHandler: WebSocketHandler, sockJsSession: WebSocketServerSockJsSession)

Functions

afterConnectionClosed

open fun afterConnectionClosed(wsSession: WebSocketSession, status: CloseStatus): Unit

afterConnectionEstablished

open fun afterConnectionEstablished(wsSession: WebSocketSession): Unit

getSubProtocols

open fun getSubProtocols(): MutableList<String>

handleTextMessage

open fun handleTextMessage(wsSession: WebSocketSession, message: TextMessage): Unit

handleTransportError

open fun handleTransportError(webSocketSession: WebSocketSession, exception: Throwable): Unit