Class StandardWebSocketSession
java.lang.Object
org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession<jakarta.websocket.Session>
org.springframework.web.reactive.socket.adapter.AbstractListenerWebSocketSession<jakarta.websocket.Session>
org.springframework.web.reactive.socket.adapter.StandardWebSocketSession
- All Implemented Interfaces:
Subscriber<Void>, WebSocketSession
- Direct Known Subclasses:
TomcatWebSocketSession
public class StandardWebSocketSession
extends AbstractListenerWebSocketSession<jakarta.websocket.Session>
Spring
WebSocketSession adapter for a standard Java (JSR 356)
Session.- Since:
- 5.0
- Author:
- Violeta Georgieva, Rossen Stoyanchev
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractListenerWebSocketSession
AbstractListenerWebSocketSession.WebSocketSendProcessor -
Field Summary
Fields inherited from class AbstractWebSocketSession
logger -
Constructor Summary
ConstructorsConstructorDescriptionStandardWebSocketSession(jakarta.websocket.Session session, HandshakeInfo info, DataBufferFactory factory) StandardWebSocketSession(jakarta.websocket.Session session, HandshakeInfo info, DataBufferFactory factory, @Nullable reactor.core.publisher.Sinks.Empty<Void> completionSink) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanWhether 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.booleanisOpen()Whether the underlying connection is open.protected voidResume receiving new message(s) after demand is generated by the downstream Subscriber.protected booleansendMessage(WebSocketMessage message) Send the given WebSocket message.protected voidSuspend receiving until received message(s) are processed and more demand is generated by the downstream Subscriber.Methods inherited from class AbstractListenerWebSocketSession
closeStatus, getSendProcessor, onComplete, onError, onNext, onSubscribe, receive, sendMethods inherited from class AbstractWebSocketSession
binaryMessage, bufferFactory, getAttributes, getDelegate, getHandshakeInfo, getId, getLogPrefix, pingMessage, pongMessage, textMessage, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface WebSocketSession
close
-
Constructor Details
-
StandardWebSocketSession
public StandardWebSocketSession(jakarta.websocket.Session session, HandshakeInfo info, DataBufferFactory factory) -
StandardWebSocketSession
public StandardWebSocketSession(jakarta.websocket.Session session, HandshakeInfo info, DataBufferFactory factory, @Nullable reactor.core.publisher.Sinks.Empty<Void> completionSink)
-
-
Method Details
-
canSuspendReceiving
protected boolean canSuspendReceiving()Description copied from class:AbstractListenerWebSocketSessionWhether 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:
canSuspendReceivingin classAbstractListenerWebSocketSession<jakarta.websocket.Session>
-
suspendReceiving
protected void suspendReceiving()Description copied from class:AbstractListenerWebSocketSessionSuspend 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 returnfalse.- Specified by:
suspendReceivingin classAbstractListenerWebSocketSession<jakarta.websocket.Session>
-
resumeReceiving
protected void resumeReceiving()Description copied from class:AbstractListenerWebSocketSessionResume 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 returnfalse.- Specified by:
resumeReceivingin classAbstractListenerWebSocketSession<jakarta.websocket.Session>
-
sendMessage
Description copied from class:AbstractListenerWebSocketSessionSend 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:
sendMessagein classAbstractListenerWebSocketSession<jakarta.websocket.Session>- Throws:
IOException
-
isOpen
public boolean isOpen()Description copied from interface:WebSocketSessionWhether the underlying connection is open. -
close
Description copied from interface:WebSocketSessionClose the WebSocket session with the given status.- Parameters:
status- the close status
-