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() |
List<String> |
getSubProtocols()
Return the list of supported sub-protocols.
|
void |
handleTextMessage(WebSocketSession wsSession,
TextMessage message) |
void |
handleTransportError(WebSocketSession webSocketSession,
Throwable exception)
Handle an error from the underlying WebSocket message transport.
|
handleBinaryMessage
handleMessage, handlePongMessage, supportsPartialMessages
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler, WebSocketServerSockJsSession sockJsSession)
public List<String> getSubProtocols()
SubProtocolCapable
getSubProtocols
in interface SubProtocolCapable
protected SockJsServiceConfig getSockJsConfig()
public void afterConnectionEstablished(WebSocketSession wsSession) throws Exception
WebSocketHandler
afterConnectionEstablished
in interface WebSocketHandler
afterConnectionEstablished
in class AbstractWebSocketHandler
Exception
- this method can handle or propagate exceptions; see class-level
Javadoc for details.public void handleTextMessage(WebSocketSession wsSession, TextMessage message) throws Exception
handleTextMessage
in class AbstractWebSocketHandler
Exception
public void afterConnectionClosed(WebSocketSession wsSession, CloseStatus status) throws Exception
WebSocketHandler
afterConnectionClosed
in interface WebSocketHandler
afterConnectionClosed
in class AbstractWebSocketHandler
Exception
- this method can handle or propagate exceptions; see class-level
Javadoc for details.public void handleTransportError(WebSocketSession webSocketSession, Throwable exception) throws Exception
WebSocketHandler
handleTransportError
in interface WebSocketHandler
handleTransportError
in class AbstractWebSocketHandler
Exception
- this method can handle or propagate exceptions; see class-level
Javadoc for details.