Class ExceptionWebSocketHandlerDecorator
- java.lang.Object
- org.springframework.web.socket.handler.WebSocketHandlerDecorator
- org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator
- All Implemented Interfaces:
WebSocketHandler
public class ExceptionWebSocketHandlerDecorator extends WebSocketHandlerDecorator
An exception handlingWebSocketHandlerDecorator
. Traps allThrowable
instances that escape from the decorated handler and closes the session withCloseStatus.SERVER_ERROR
.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description ExceptionWebSocketHandlerDecorator(WebSocketHandler delegate)
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus)
Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred.void
afterConnectionEstablished(WebSocketSession session)
Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.void
handleMessage(WebSocketSession session, WebSocketMessage<?> message)
Invoked when a new WebSocket message arrives.void
handleTransportError(WebSocketSession session, Throwable exception)
Handle an error from the underlying WebSocket message transport.static void
tryCloseWithError(WebSocketSession session, Throwable exception, Log logger)
Methods inherited from class org.springframework.web.socket.handler.WebSocketHandlerDecorator
getDelegate, getLastHandler, supportsPartialMessages, toString, unwrap
Constructor Detail
ExceptionWebSocketHandlerDecorator
public ExceptionWebSocketHandlerDecorator(WebSocketHandler delegate)
Method Detail
afterConnectionEstablished
public void afterConnectionEstablished(WebSocketSession session)
Description copied from interface:WebSocketHandler
Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.- Specified by:
afterConnectionEstablished
in interfaceWebSocketHandler
- Overrides:
afterConnectionEstablished
in classWebSocketHandlerDecorator
handleMessage
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message)
Description copied from interface:WebSocketHandler
Invoked when a new WebSocket message arrives.- Specified by:
handleMessage
in interfaceWebSocketHandler
- Overrides:
handleMessage
in classWebSocketHandlerDecorator
handleTransportError
public void handleTransportError(WebSocketSession session, Throwable exception)
Description copied from interface:WebSocketHandler
Handle an error from the underlying WebSocket message transport.- Specified by:
handleTransportError
in interfaceWebSocketHandler
- Overrides:
handleTransportError
in classWebSocketHandlerDecorator
afterConnectionClosed
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus)
Description copied from interface:WebSocketHandler
Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred. Although the session may technically still be open, depending on the underlying implementation, sending messages at this point is discouraged and most likely will not succeed.- Specified by:
afterConnectionClosed
in interfaceWebSocketHandler
- Overrides:
afterConnectionClosed
in classWebSocketHandlerDecorator
tryCloseWithError
public static void tryCloseWithError(WebSocketSession session, Throwable exception, Log logger)