public class SockJsWebSocketHandler extends TextWebSocketHandlerAdapter
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(SockJsConfiguration config,
WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession session) |
| 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 SockJsConfiguration |
getSockJsConfig() |
void |
handleTextMessage(WebSocketSession wsSession,
TextMessage message) |
void |
handleTransportError(WebSocketSession webSocketSession,
java.lang.Throwable exception)
Handle an error from the underlying WebSocket message transport.
|
handleBinaryMessagehandleMessage, supportsPartialMessagespublic SockJsWebSocketHandler(SockJsConfiguration config, WebSocketHandler webSocketHandler, WebSocketServerSockJsSession session)
protected SockJsConfiguration getSockJsConfig()
public void afterConnectionEstablished(WebSocketSession wsSession) throws java.lang.Exception
WebSocketHandlerafterConnectionEstablished in interface WebSocketHandlerafterConnectionEstablished in class WebSocketHandlerAdapterjava.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 WebSocketHandlerAdapterjava.lang.Exceptionpublic void afterConnectionClosed(WebSocketSession wsSession, CloseStatus status) throws java.lang.Exception
WebSocketHandlerafterConnectionClosed in interface WebSocketHandlerafterConnectionClosed in class WebSocketHandlerAdapterjava.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
WebSocketHandlerhandleTransportError in interface WebSocketHandlerhandleTransportError in class WebSocketHandlerAdapterjava.lang.Exception - this method can handle or propagate exceptions; see class-level
Javadoc for details.