org.springframework.web.reactive.socket.adapter

## Class ContextWebSocketHandler

- java.lang.Object
- - org.springframework.web.reactive.socket.adapter.ContextWebSocketHandler

- All Implemented Interfaces:
    WebSocketHandler

      public final class ContextWebSocketHandler
      extends Object
      implements WebSocketHandler

  `WebSocketHandler` decorator that enriches the context of the target handler.
  Since:
    5.3.3
  Author:
    Rossen Stoyanchev

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static WebSocketHandler` | `decorate(WebSocketHandler handler, reactor.util.context.ContextView contextView)` Return the given handler, decorated to insert the given context, or the same handler instance when the context is empty.
    `List<String>` | `getSubProtocols()` Return the list of sub-protocols supported by this handler.
    `reactor.core.publisher.Mono<Void>` | `handle(WebSocketSession session)` Invoked when a new WebSocket connection is established, and allows handling of the session.

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

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

- - ### Method Detail

    - #### getSubProtocols

          public List<String> getSubProtocols()

      Description copied from interface: `WebSocketHandler`
      Return the list of sub-protocols supported by this handler.

      By default an empty list is returned.

      Specified by:
        `getSubProtocols` in interface `WebSocketHandler`

    - #### handle

          public reactor.core.publisher.Mono<Void> handle(WebSocketSession session)

      Description copied from interface: `WebSocketHandler`
      Invoked when a new WebSocket connection is established, and allows handling of the session.

      See the class-level doc and the reference manual for more details and examples of how to handle the session.

      Specified by:
        `handle` in interface `WebSocketHandler`
      Parameters:
        `session` - the session to handle
      Returns:
        indicates when application handling of the session is complete, which should reflect the completion of the inbound message stream (i.e. connection closing) and possibly the completion of the outbound message stream and the writing of messages

    - #### decorate

          public static WebSocketHandler decorate(WebSocketHandler handler,
                                                  reactor.util.context.ContextView contextView)

      Return the given handler, decorated to insert the given context, or the same handler instance when the context is empty.