spring-framework / org.springframework.web.socket.handler / ConcurrentWebSocketSessionDecorator

ConcurrentWebSocketSessionDecorator

open class ConcurrentWebSocketSessionDecorator : WebSocketSessionDecorator

Wrap a org.springframework.web.socket.WebSocketSession to guarantee only one thread can send messages at a time.

If a send is slow, subsequent attempts to send more messages from other threads will not be able to acquire the flush lock and messages will be buffered instead. At that time, the specified buffer-size limit and send-time limit will be checked and the session will be closed if the limits are exceeded.

Author
Rossen Stoyanchev

Author
Juergen Hoeller

Since
4.0.3

Constructors

<init>

ConcurrentWebSocketSessionDecorator(delegate: WebSocketSession, sendTimeLimit: Int, bufferSizeLimit: Int)

Create a new ConcurrentWebSocketSessionDecorator.

Functions

close

open fun close(status: CloseStatus): Unit

getBufferSize

open fun getBufferSize(): Int

Return the current buffer size (number of bytes).

getBufferSizeLimit

open fun getBufferSizeLimit(): Int

Return the configured buffer-size limit (number of bytes).

getSendTimeLimit

open fun getSendTimeLimit(): Int

Return the configured send-time limit (milliseconds).

getTimeSinceSendStarted

open fun getTimeSinceSendStarted(): Long

Return the time (milliseconds) since the current send started, or 0 if no send is currently in progress.

sendMessage

open fun sendMessage(message: WebSocketMessage<*>): Unit

toString

open fun toString(): String