public class SockJsWebSocketHandler extends TextWebSocketHandler implements SubProtocolCapable
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.
Constructor and Description |
---|
SockJsWebSocketHandler(SockJsServiceConfig serviceConfig,
WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession sockJsSession) |
Modifier and Type | Method and Description |
---|---|
void |
afterConnectionClosed(WebSocketSession wsSession,
CloseStatus status)
Invoked after the WebSocket connection has been closed by either side, or after a
transport error has occurred.
|
void |
afterConnectionEstablished(WebSocketSession wsSession)
Invoked after WebSocket negotiation has succeeded and the WebSocket connection is
opened and ready for use.
|
protected SockJsServiceConfig |
getSockJsConfig() |
java.util.List<java.lang.String> |
getSubProtocols()
Return the list of supported sub-protocols.
|
void |
handleTextMessage(WebSocketSession wsSession,
TextMessage message) |
void |
handleTransportError(WebSocketSession webSocketSession,
java.lang.Throwable exception)
Handle an error from the underlying WebSocket message transport.
|
handleBinaryMessage
handleMessage, handlePongMessage, supportsPartialMessages
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler, WebSocketServerSockJsSession sockJsSession)
public java.util.List<java.lang.String> getSubProtocols()
SubProtocolCapable
getSubProtocols
in interface SubProtocolCapable
protected SockJsServiceConfig getSockJsConfig()
public void afterConnectionEstablished(WebSocketSession wsSession) throws java.lang.Exception
WebSocketHandler
afterConnectionEstablished
in interface WebSocketHandler
afterConnectionEstablished
in class AbstractWebSocketHandler
java.lang.Exception
- this method can handle or propagate exceptions; see class-level
Javadoc for details.public void handleTextMessage(WebSocketSession wsSession, TextMessage message) throws java.lang.Exception
handleTextMessage
in class AbstractWebSocketHandler
java.lang.Exception
public void afterConnectionClosed(WebSocketSession wsSession, CloseStatus status) throws java.lang.Exception
WebSocketHandler
afterConnectionClosed
in interface WebSocketHandler
afterConnectionClosed
in class AbstractWebSocketHandler
java.lang.Exception
- this method can handle or propagate exceptions; see class-level
Javadoc for details.public void handleTransportError(WebSocketSession webSocketSession, java.lang.Throwable exception) throws java.lang.Exception
WebSocketHandler
handleTransportError
in interface WebSocketHandler
handleTransportError
in class AbstractWebSocketHandler
java.lang.Exception
- this method can handle or propagate exceptions; see class-level
Javadoc for details.