public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorator
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 closed if the limits are exceeded.
| Constructor and Description |
|---|
ConcurrentWebSocketSessionDecorator(WebSocketSession delegate,
int sendTimeLimit,
int bufferSizeLimit)
Create a new
ConcurrentWebSocketSessionDecorator. |
| Modifier and Type | Method and Description |
|---|---|
void |
close(CloseStatus status)
Close the WebSocket connection with the given close status.
|
int |
getBufferSize() |
long |
getTimeSinceSendStarted() |
void |
sendMessage(WebSocketMessage<?> message)
Send a WebSocket message: either
TextMessage or BinaryMessage. |
String |
toString() |
close, getAcceptedProtocol, getAttributes, getBinaryMessageSizeLimit, getDelegate, getExtensions, getHandshakeHeaders, getId, getLastSession, getLocalAddress, getPrincipal, getRemoteAddress, getTextMessageSizeLimit, getUri, isOpen, setBinaryMessageSizeLimit, setTextMessageSizeLimit, unwrappublic ConcurrentWebSocketSessionDecorator(WebSocketSession delegate, int sendTimeLimit, int bufferSizeLimit)
ConcurrentWebSocketSessionDecorator.delegate - the WebSocketSession to delegate tosendTimeLimit - the send-time limit (milliseconds)bufferSizeLimit - the buffer-size limit (number of bytes)public int getBufferSize()
public long getTimeSinceSendStarted()
public void sendMessage(WebSocketMessage<?> message) throws IOException
WebSocketSessionTextMessage or BinaryMessage.sendMessage in interface WebSocketSessionsendMessage in class WebSocketSessionDecoratorIOExceptionpublic void close(CloseStatus status) throws IOException
WebSocketSessionclose in interface WebSocketSessionclose in class WebSocketSessionDecoratorIOExceptionpublic String toString()
toString in class WebSocketSessionDecorator