Class WebSocketHandlerDecorator
java.lang.Object
org.springframework.web.socket.handler.WebSocketHandlerDecorator
- All Implemented Interfaces:
WebSocketHandler
- Direct Known Subclasses:
ExceptionWebSocketHandlerDecorator
,LoggingWebSocketHandlerDecorator
Wraps another
WebSocketHandler
instance and delegates to it.
Also provides a getDelegate()
method to return the decorated
handler as well as a getLastHandler()
method to go through all nested
delegates and return the "last" handler.
- Since:
- 4.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterConnectionClosed
(WebSocketSession session, CloseStatus closeStatus) Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred.void
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.boolean
Whether the WebSocketHandler handles partial messages.toString()
static WebSocketHandler
unwrap
(WebSocketHandler handler)
-
Constructor Details
-
WebSocketHandlerDecorator
-
-
Method Details
-
getDelegate
-
getLastHandler
-
unwrap
-
afterConnectionEstablished
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
- Throws:
Exception
- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
handleMessage
Description copied from interface:WebSocketHandler
Invoked when a new WebSocket message arrives.- Specified by:
handleMessage
in interfaceWebSocketHandler
- Throws:
Exception
- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
handleTransportError
Description copied from interface:WebSocketHandler
Handle an error from the underlying WebSocket message transport.- Specified by:
handleTransportError
in interfaceWebSocketHandler
- Throws:
Exception
- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
afterConnectionClosed
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception 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
- Throws:
Exception
- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
supportsPartialMessages
public boolean supportsPartialMessages()Description copied from interface:WebSocketHandler
Whether the WebSocketHandler handles partial messages. If this flag is set totrue
and the underlying WebSocket server supports partial messages, then a large WebSocket message, or one of an unknown size may be split and maybe received over multiple calls toWebSocketHandler.handleMessage(WebSocketSession, WebSocketMessage)
. The flagWebSocketMessage.isLast()
indicates if the message is partial and whether it is the last part.- Specified by:
supportsPartialMessages
in interfaceWebSocketHandler
-
toString
-