Class AbstractWebSocketHandler
java.lang.Object
org.springframework.web.socket.handler.AbstractWebSocketHandler
- All Implemented Interfaces:
WebSocketHandler
- Direct Known Subclasses:
BinaryWebSocketHandler,TextWebSocketHandler
A convenient base class for
WebSocketHandler implementation with empty methods.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Phillip Webb
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterConnectionClosed(WebSocketSession session, CloseStatus status) Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred.voidInvoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.protected voidhandleBinaryMessage(WebSocketSession session, BinaryMessage message) voidhandleMessage(WebSocketSession session, WebSocketMessage<?> message) Invoked when a new WebSocket message arrives.protected voidhandlePongMessage(WebSocketSession session, PongMessage message) protected voidhandleTextMessage(WebSocketSession session, TextMessage message) voidhandleTransportError(WebSocketSession session, Throwable exception) Handle an error from the underlying WebSocket message transport.booleanWhether the WebSocketHandler handles partial messages.
-
Constructor Details
-
AbstractWebSocketHandler
public AbstractWebSocketHandler()
-
-
Method Details
-
afterConnectionEstablished
Description copied from interface:WebSocketHandlerInvoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.- Specified by:
afterConnectionEstablishedin interfaceWebSocketHandler- Throws:
Exception- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
handleMessage
Description copied from interface:WebSocketHandlerInvoked when a new WebSocket message arrives.- Specified by:
handleMessagein interfaceWebSocketHandler- Throws:
Exception- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
handleTextMessage
- Throws:
Exception
-
handleBinaryMessage
protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception - Throws:
Exception
-
handlePongMessage
- Throws:
Exception
-
handleTransportError
Description copied from interface:WebSocketHandlerHandle an error from the underlying WebSocket message transport.- Specified by:
handleTransportErrorin interfaceWebSocketHandler- Throws:
Exception- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
afterConnectionClosed
Description copied from interface:WebSocketHandlerInvoked 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:
afterConnectionClosedin interfaceWebSocketHandler- Throws:
Exception- this method can handle or propagate exceptions; see class-level Javadoc for details.
-
supportsPartialMessages
public boolean supportsPartialMessages()Description copied from interface:WebSocketHandlerWhether the WebSocketHandler handles partial messages. If this flag is set totrueand 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:
supportsPartialMessagesin interfaceWebSocketHandler
-