T - the native delegate typepublic abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSocketSession<T> implements org.reactivestreams.Subscriber<Void>
WebSocketSession implementations that bridge between
event-listener WebSocket APIs (e.g. Java WebSocket API JSR-356, Jetty,
Undertow) and Reactive Streams.
Also implements Subscriber<Void> so it can be used to subscribe to
the completion of WebSocketHandler.handle(WebSocketSession).
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractListenerWebSocketSession.WebSocketSendProcessor
Processor to send web socket messages.
|
logger| Constructor and Description |
|---|
AbstractListenerWebSocketSession(T delegate,
String id,
HandshakeInfo info,
DataBufferFactory bufferFactory)
Base constructor.
|
AbstractListenerWebSocketSession(T delegate,
String id,
HandshakeInfo info,
DataBufferFactory bufferFactory,
reactor.core.publisher.MonoProcessor<Void> handlerCompletion)
Deprecated.
|
AbstractListenerWebSocketSession(T delegate,
String id,
HandshakeInfo info,
DataBufferFactory bufferFactory,
reactor.core.publisher.Sinks.Empty<Void> handlerCompletionSink)
Alternative constructor with completion sink to use to signal when the
handling of the session is complete, with success or error.
|
| 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.
|
reactor.core.publisher.Mono<CloseStatus> |
closeStatus()
Provides access to the
CloseStatus with which the session is
closed either locally or remotely, or completes empty if the session ended
without a status. |
protected AbstractListenerWebSocketSession.WebSocketSendProcessor |
getSendProcessor() |
void |
onComplete() |
void |
onError(Throwable ex) |
void |
onNext(Void aVoid) |
void |
onSubscribe(org.reactivestreams.Subscription subscription) |
reactor.core.publisher.Flux<WebSocketMessage> |
receive()
Provides access to the stream of inbound messages.
|
protected abstract void |
resumeReceiving()
Resume receiving new message(s) after demand is generated by the
downstream Subscriber.
|
reactor.core.publisher.Mono<Void> |
send(org.reactivestreams.Publisher<WebSocketMessage> messages)
Give a source of outgoing messages, write the messages and return a
Mono<Void> that completes when the source completes and writing
is done. |
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, getAttributes, getDelegate, getHandshakeInfo, getId, getLogPrefix, pingMessage, pongMessage, textMessage, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, close, isOpenpublic AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo info, DataBufferFactory bufferFactory)
delegate - the native WebSocket session, channel, or connectionid - the session idinfo - the handshake infobufferFactory - the DataBuffer factor for the current connectionpublic AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo info, DataBufferFactory bufferFactory, @Nullable reactor.core.publisher.Sinks.Empty<Void> handlerCompletionSink)
Primarily for use with WebSocketClient to be able to
communicate the end of handling.
@Deprecated public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo info, DataBufferFactory bufferFactory, @Nullable reactor.core.publisher.MonoProcessor<Void> handlerCompletion)
AbstractListenerWebSocketSession(Object, String, HandshakeInfo, DataBufferFactory, Sinks.Empty)Primarily for use with WebSocketClient to be able to
communicate the end of handling.
protected AbstractListenerWebSocketSession.WebSocketSendProcessor getSendProcessor()
public reactor.core.publisher.Flux<WebSocketMessage> receive()
WebSocketSessionThis stream receives a completion or error signal when the connection
is closed. In a typical WebSocketHandler implementation this
stream is composed into the overall processing flow, so that when the
connection is closed, handling will end.
See the class-level doc of WebSocketHandler and the reference
for more details and examples of how to handle the session.
receive in interface WebSocketSessionreceive in class AbstractWebSocketSession<T>public reactor.core.publisher.Mono<Void> send(org.reactivestreams.Publisher<WebSocketMessage> messages)
WebSocketSessionMono<Void> that completes when the source completes and writing
is done.
See the class-level doc of WebSocketHandler and the reference
for more details and examples of how to handle the session.
send in interface WebSocketSessionsend in class AbstractWebSocketSession<T>public reactor.core.publisher.Mono<CloseStatus> closeStatus()
WebSocketSessionCloseStatus with which the session is
closed either locally or remotely, or completes empty if the session ended
without a status.closeStatus in interface WebSocketSessionprotected abstract boolean canSuspendReceiving()
Note: Sub-classes are encouraged to start out in suspended mode, if possible, and wait until demand is received.
protected abstract void suspendReceiving()
Note: if the underlying WebSocket API does not provide
flow control for receiving messages, 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, this method should be a no-op
and canSuspendReceiving() should return false.
protected abstract boolean sendMessage(WebSocketMessage message) throws IOException
Note: Sub-classes are responsible for releasing the payload data buffer, once fully written, if pooled buffers apply to the underlying container.
IOExceptionpublic void onSubscribe(org.reactivestreams.Subscription subscription)
onSubscribe in interface org.reactivestreams.Subscriber<Void>public void onNext(Void aVoid)
onNext in interface org.reactivestreams.Subscriber<Void>public void onError(Throwable ex)
onError in interface org.reactivestreams.Subscriber<Void>public void onComplete()
onComplete in interface org.reactivestreams.Subscriber<Void>