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