org.springframework.web.reactive.socket.adapter

## Class UndertowWebSocketSession

- java.lang.Object
- - org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession<T>
  - - org.springframework.web.reactive.socket.adapter.AbstractListenerWebSocketSession<io.undertow.websockets.core.WebSocketChannel>
    - - org.springframework.web.reactive.socket.adapter.UndertowWebSocketSession

- All Implemented Interfaces:
    Subscriber<Void>, WebSocketSession

      public class UndertowWebSocketSession
      extends AbstractListenerWebSocketSession<io.undertow.websockets.core.WebSocketChannel>

  Spring `WebSocketSession` implementation that adapts to an Undertow `WebSocketChannel`.
  Since:
    5.0
  Author:
    Violeta Georgieva, Rossen Stoyanchev

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.springframework.web.reactive.socket.adapter.AbstractListenerWebSocketSession

      `AbstractListenerWebSocketSession.WebSocketSendProcessor`

  - ### Field Summary

    - ### Fields inherited from class org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UndertowWebSocketSession(io.undertow.websockets.core.WebSocketChannel channel, HandshakeInfo info, DataBufferFactory factory)`
    `UndertowWebSocketSession(io.undertow.websockets.core.WebSocketChannel channel, HandshakeInfo info, DataBufferFactory factory, reactor.core.publisher.MonoProcessor<Void> completionMono)` Deprecated.
    `UndertowWebSocketSession(io.undertow.websockets.core.WebSocketChannel channel, HandshakeInfo info, DataBufferFactory factory, reactor.core.publisher.Sinks.Empty<Void> completionSink)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `canSuspendReceiving()` Whether the underlying WebSocket API has flow control and can suspend and resume the receiving of messages.
    `reactor.core.publisher.Mono<Void>` | `close(CloseStatus status)` Close the WebSocket session with the given status.
    `boolean` | `isOpen()` Whether the underlying connection is open.
    `protected void` | `resumeReceiving()` Resume receiving new message(s) after demand is generated by the downstream Subscriber.
    `protected boolean` | `sendMessage(WebSocketMessage message)` Send the given WebSocket message.
    `protected void` | `suspendReceiving()` Suspend receiving until received message(s) are processed and more demand is generated by the downstream Subscriber.

    - ### Methods inherited from class org.springframework.web.reactive.socket.adapter.AbstractListenerWebSocketSession

      `closeStatus, getSendProcessor, onComplete, onError, onNext, onSubscribe, receive, send`

    - ### Methods inherited from class org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession

      `binaryMessage, bufferFactory, getAttributes, getDelegate, getHandshakeInfo, getId, getLogPrefix, pingMessage, pongMessage, textMessage, toString`

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

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

    - ### Methods inherited from interface org.springframework.web.reactive.socket.WebSocketSession

      `close`

- - ### Constructor Detail

    - #### UndertowWebSocketSession

          public UndertowWebSocketSession(io.undertow.websockets.core.WebSocketChannel channel,
                                          HandshakeInfo info,
                                          DataBufferFactory factory)

    - #### UndertowWebSocketSession

          public UndertowWebSocketSession(io.undertow.websockets.core.WebSocketChannel channel,
                                          HandshakeInfo info,
                                          DataBufferFactory factory,
                                          @Nullable
                                          reactor.core.publisher.Sinks.Empty<Void> completionSink)

    - #### UndertowWebSocketSession

          @Deprecated
          public UndertowWebSocketSession(io.undertow.websockets.core.WebSocketChannel channel,
                                                      HandshakeInfo info,
                                                      DataBufferFactory factory,
                                                      @Nullable
                                                      reactor.core.publisher.MonoProcessor<Void> completionMono)

      Deprecated.

  - ### Method Detail

    - #### canSuspendReceiving

          protected boolean canSuspendReceiving()

      Description copied from class: `AbstractListenerWebSocketSession`
      Whether the underlying WebSocket API has flow control and can suspend and resume the receiving of messages.

      Note: Sub-classes are encouraged to start out in suspended mode, if possible, and wait until demand is received.

      Specified by:
        `canSuspendReceiving` in class `AbstractListenerWebSocketSession<io.undertow.websockets.core.WebSocketChannel>`

    - #### suspendReceiving

          protected void suspendReceiving()

      Description copied from class: `AbstractListenerWebSocketSession`
      Suspend receiving until received message(s) are processed and more demand is generated by the downstream Subscriber.

      Note: if the underlying WebSocket API does not provide flow control for receiving messages, this method should be a no-op and `AbstractListenerWebSocketSession.canSuspendReceiving()` should return `false`.

      Specified by:
        `suspendReceiving` in class `AbstractListenerWebSocketSession<io.undertow.websockets.core.WebSocketChannel>`

    - #### resumeReceiving

          protected void resumeReceiving()

      Description copied from class: `AbstractListenerWebSocketSession`
      Resume receiving new message(s) after demand is generated by the downstream Subscriber.

      Note: if the underlying WebSocket API does not provide flow control for receiving messages, this method should be a no-op and `AbstractListenerWebSocketSession.canSuspendReceiving()` should return `false`.

      Specified by:
        `resumeReceiving` in class `AbstractListenerWebSocketSession<io.undertow.websockets.core.WebSocketChannel>`

    - #### sendMessage

          protected boolean sendMessage(WebSocketMessage message)
                                 throws IOException

      Description copied from class: `AbstractListenerWebSocketSession`
      Send the given WebSocket message.

      Note: Sub-classes are responsible for releasing the payload data buffer, once fully written, if pooled buffers apply to the underlying container.

      Specified by:
        `sendMessage` in class `AbstractListenerWebSocketSession<io.undertow.websockets.core.WebSocketChannel>`
      Throws:
        `IOException`

    - #### isOpen

          public boolean isOpen()

      Description copied from interface: `WebSocketSession`
      Whether the underlying connection is open.

    - #### close

          public reactor.core.publisher.Mono<Void> close(CloseStatus status)

      Description copied from interface: `WebSocketSession`
      Close the WebSocket session with the given status.
      Parameters:
        `status` - the close status