org.springframework.web.socket.handler

## Class ConcurrentWebSocketSessionDecorator

- java.lang.Object
- - org.springframework.web.socket.handler.WebSocketSessionDecorator
  - - org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator

- All Implemented Interfaces:
    WebSocketSession

      public class ConcurrentWebSocketSessionDecorator
      extends WebSocketSessionDecorator

  Wraps a `WebSocketSession` and guarantees only one thread can send messages at a time.

  If a send is slow, subsequent attempts to send more messages from a different thread will fail to acquire the flushLock and the messages will be buffered instead -- at that time the specified buffer size limit and send time limit will be checked and the session closed if the limits are exceeded.

  Since:
    4.0.3
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConcurrentWebSocketSessionDecorator(WebSocketSession delegate, int sendTimeLimit, int bufferSizeLimit)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getBufferSize()`
    `long` | `getTimeSinceSendStarted()`
    `void` | `sendMessage(WebSocketMessage<?> message)` Send a WebSocket message either `TextMessage` or `BinaryMessage`.

    - ### Methods inherited from class org.springframework.web.socket.handler.WebSocketSessionDecorator

      `close, close, getAcceptedProtocol, getAttributes, getBinaryMessageSizeLimit, getDelegate, getExtensions, getHandshakeHeaders, getId, getLastSession, getLocalAddress, getPrincipal, getRemoteAddress, getTextMessageSizeLimit, getUri, isOpen, setBinaryMessageSizeLimit, setTextMessageSizeLimit, toString, unwrap`

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

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

- - ### Constructor Detail

    - #### ConcurrentWebSocketSessionDecorator

          public ConcurrentWebSocketSessionDecorator(WebSocketSession delegate,
                                                     int sendTimeLimit,
                                                     int bufferSizeLimit)

  - ### Method Detail

    - #### getBufferSize

          public int getBufferSize()

    - #### getTimeSinceSendStarted

          public long getTimeSinceSendStarted()

    - #### sendMessage

          public void sendMessage(WebSocketMessage<?> message)
                           throws IOException

      Description copied from interface: `WebSocketSession`
      Send a WebSocket message either `TextMessage` or `BinaryMessage`.
      Specified by:
        `sendMessage` in interface `WebSocketSession`
      Overrides:
        `sendMessage` in class `WebSocketSessionDecorator`
      Throws:
        `IOException`