public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSocketSession<T> implements org.reactivestreams.Subscriber<java.lang.Void>
WebSocketSession implementations that bridge between
event-listener WebSocket APIs (e.g. Java WebSocket API JSR-356, Jetty,
Undertow) and Reactive Streams.
Also an implementation of Subscriber<Void> so it can be used as
the completion subscriber for session handling
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractListenerWebSocketSession.WebSocketSendProcessor |
| Constructor and Description |
|---|
AbstractListenerWebSocketSession(T delegate,
java.lang.String id,
HandshakeInfo handshakeInfo,
org.springframework.core.io.buffer.DataBufferFactory bufferFactory)
Base constructor.
|
AbstractListenerWebSocketSession(T delegate,
java.lang.String id,
HandshakeInfo handshakeInfo,
org.springframework.core.io.buffer.DataBufferFactory bufferFactory,
reactor.core.publisher.MonoProcessor<java.lang.Void> completionMono)
Alternative constructor with completion
Mono<Void> to propagate
the session completion (success or error) (for client-side use). |
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
canSuspendReceiving()
Whether the underlying WebSocket API has flow control and can suspend and
resume the receiving of messages.
|
protected AbstractListenerWebSocketSession.WebSocketSendProcessor |
getSendProcessor() |
void |
onComplete() |
void |
onError(java.lang.Throwable ex) |
void |
onNext(java.lang.Void aVoid) |
void |
onSubscribe(org.reactivestreams.Subscription subscription) |
reactor.core.publisher.Flux<WebSocketMessage> |
receive()
Get the flux of incoming messages.
|
protected abstract void |
resumeReceiving()
Resume receiving new message(s) after demand is generated by the
downstream Subscriber.
|
reactor.core.publisher.Mono<java.lang.Void> |
send(org.reactivestreams.Publisher<WebSocketMessage> messages)
Write the given messages to the WebSocket connection.
|
protected abstract boolean |
sendMessage(WebSocketMessage message)
Send the given WebSocket message.
|
protected abstract void |
suspendReceiving()
Suspend receiving until received message(s) are processed and more demand
is generated by the downstream Subscriber.
|
binaryMessage, bufferFactory, getDelegate, getHandshakeInfo, getId, pingMessage, pongMessage, textMessage, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, closepublic AbstractListenerWebSocketSession(T delegate, java.lang.String id, HandshakeInfo handshakeInfo, org.springframework.core.io.buffer.DataBufferFactory bufferFactory)
delegate - the native WebSocket session, channel, or connectionid - the session idhandshakeInfo - the handshake infobufferFactory - the DataBuffer factor for the current connectionpublic AbstractListenerWebSocketSession(T delegate, java.lang.String id, HandshakeInfo handshakeInfo, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, @Nullable reactor.core.publisher.MonoProcessor<java.lang.Void> completionMono)
Mono<Void> to propagate
the session completion (success or error) (for client-side use).protected AbstractListenerWebSocketSession.WebSocketSendProcessor getSendProcessor()
public reactor.core.publisher.Flux<WebSocketMessage> receive()
WebSocketSessionreceive in interface WebSocketSessionreceive in class AbstractWebSocketSession<T>public reactor.core.publisher.Mono<java.lang.Void> send(org.reactivestreams.Publisher<WebSocketMessage> messages)
WebSocketSessionsend in interface WebSocketSessionsend in class AbstractWebSocketSession<T>messages - the messages to writeprotected abstract boolean canSuspendReceiving()
protected abstract void suspendReceiving()
Note: if the underlying WebSocket API does not provide
flow control for receiving messages, and this method should be a no-op
and canSuspendReceiving() should return false.
protected abstract void resumeReceiving()
Note: if the underlying WebSocket API does not provide
flow control for receiving messages, and this method should be a no-op
and canSuspendReceiving() should return false.
protected abstract boolean sendMessage(WebSocketMessage message) throws java.io.IOException
java.io.IOExceptionpublic void onSubscribe(org.reactivestreams.Subscription subscription)
onSubscribe in interface org.reactivestreams.Subscriber<java.lang.Void>public void onNext(java.lang.Void aVoid)
onNext in interface org.reactivestreams.Subscriber<java.lang.Void>public void onError(java.lang.Throwable ex)
onError in interface org.reactivestreams.Subscriber<java.lang.Void>public void onComplete()
onComplete in interface org.reactivestreams.Subscriber<java.lang.Void>