org.springframework.web.socket.handler

## Class AbstractWebSocketHandler

- java.lang.Object
- - org.springframework.web.socket.handler.AbstractWebSocketHandler

All Implemented Interfaces:
  WebSocketHandler

Direct Known Subclasses:
  BinaryWebSocketHandler, TextWebSocketHandler

    public abstract class AbstractWebSocketHandler
    extends Object
    implements WebSocketHandler

A convenient base class for `WebSocketHandler` implementation with empty methods.

Since:
  4.0
Author:
  Rossen Stoyanchev, Phillip Webb

### Constructor Summary

Constructors
Constructor and Description
`AbstractWebSocketHandler()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterConnectionClosed(WebSocketSession session, CloseStatus status)` 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.
`protected void` `handleBinaryMessage(WebSocketSession session, BinaryMessage message)`
`void` `handleMessage(WebSocketSession session, WebSocketMessage<?> message)` Invoked when a new WebSocket message arrives.
`protected void` `handlePongMessage(WebSocketSession session, PongMessage message)`
`protected void` `handleTextMessage(WebSocketSession session, TextMessage message)`
`void` `handleTransportError(WebSocketSession session, Throwable exception)` Handle an error from the underlying WebSocket message transport.
`boolean` `supportsPartialMessages()` Whether the WebSocketHandler handles partial messages.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractWebSocketHandler

    public AbstractWebSocketHandler()

### Method Detail

#### afterConnectionEstablished

    public void afterConnectionEstablished(WebSocketSession session)
                                    throws Exception

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 interface `WebSocketHandler`
Throws:
  `Exception` - this method can handle or propagate exceptions; see class-level Javadoc for details.

#### handleMessage

    public void handleMessage(WebSocketSession session,
                              WebSocketMessage<?> message)
                       throws Exception

Description copied from interface: `WebSocketHandler`
Invoked when a new WebSocket message arrives.

Specified by:
  `handleMessage` in interface `WebSocketHandler`
Throws:
  `Exception` - this method can handle or propagate exceptions; see class-level Javadoc for details.

#### handleTextMessage

    protected void handleTextMessage(WebSocketSession session,
                                     TextMessage message)
                              throws Exception

Throws:
  `Exception`

#### handleBinaryMessage

    protected void handleBinaryMessage(WebSocketSession session,
                                       BinaryMessage message)
                                throws Exception

Throws:
  `Exception`

#### handlePongMessage

    protected void handlePongMessage(WebSocketSession session,
                                     PongMessage message)
                              throws Exception

Throws:
  `Exception`

#### handleTransportError

    public void handleTransportError(WebSocketSession session,
                                     Throwable exception)
                              throws Exception

Description copied from interface: `WebSocketHandler`
Handle an error from the underlying WebSocket message transport.

Specified by:
  `handleTransportError` in interface `WebSocketHandler`
Throws:
  `Exception` - this method can handle or propagate exceptions; see class-level Javadoc for details.

#### afterConnectionClosed

    public void afterConnectionClosed(WebSocketSession session,
                                      CloseStatus status)
                               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 interface `WebSocketHandler`
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 to `true` 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 to `WebSocketHandler.handleMessage(WebSocketSession, WebSocketMessage)`. The flag `WebSocketMessage.isLast()` indicates if the message is partial and whether it is the last part.

Specified by:
  `supportsPartialMessages` in interface `WebSocketHandler`