类 AbstractListenerWebSocketSession<T>
- java.lang.Object
- org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession<T>
- org.springframework.web.reactive.socket.adapter.AbstractListenerWebSocketSession<T>
- 类型参数:
T
- the native delegate type
- 所有已实现的接口:
org.reactivestreams.Subscriber<Void>
,WebSocketSession
public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSocketSession<T> implements org.reactivestreams.Subscriber<Void>
Base class forWebSocketSession
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- 从以下版本开始:
- 5.0
- 作者:
- Violeta Georgieva, Rossen Stoyanchev
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected class
AbstractListenerWebSocketSession.WebSocketSendProcessor
Processor to send web socket messages.
字段概要
从类继承的字段 org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession
logger
构造器概要
构造器 构造器 说明 AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo handshakeInfo, DataBufferFactory bufferFactory)
Base constructor.AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo info, DataBufferFactory bufferFactory, reactor.core.publisher.MonoProcessor<Void> completionMono)
Alternative constructor with completionMono<Void>
to propagate the session completion (success or error) (for client-side use).
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 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(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 aMono<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.从类继承的方法 org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession
binaryMessage, bufferFactory, getAttributes, getDelegate, getHandshakeInfo, getId, getLogPrefix, pingMessage, pongMessage, textMessage, toString
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.web.reactive.socket.WebSocketSession
close, close
构造器详细资料
AbstractListenerWebSocketSession
public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo handshakeInfo, DataBufferFactory bufferFactory)
Base constructor.- 参数:
delegate
- the native WebSocket session, channel, or connectionid
- the session idhandshakeInfo
- the handshake infobufferFactory
- the DataBuffer factor for the current connection
AbstractListenerWebSocketSession
public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo info, DataBufferFactory bufferFactory, @Nullable reactor.core.publisher.MonoProcessor<Void> completionMono)
Alternative constructor with completionMono<Void>
to propagate the session completion (success or error) (for client-side use).
方法详细资料
getSendProcessor
protected AbstractListenerWebSocketSession.WebSocketSendProcessor getSendProcessor()
receive
public reactor.core.publisher.Flux<WebSocketMessage> receive()
从接口复制的说明:WebSocketSession
Provides access to the stream of inbound messages.This 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
在接口中WebSocketSession
- 指定者:
receive
在类中AbstractWebSocketSession<T>
send
public reactor.core.publisher.Mono<Void> send(org.reactivestreams.Publisher<WebSocketMessage> messages)
从接口复制的说明:WebSocketSession
Give a source of outgoing messages, write the messages and return aMono<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
在接口中WebSocketSession
- 指定者:
send
在类中AbstractWebSocketSession<T>
canSuspendReceiving
protected abstract boolean canSuspendReceiving()
Whether 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.
suspendReceiving
protected abstract void suspendReceiving()
Suspend 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
canSuspendReceiving()
should returnfalse
.
resumeReceiving
protected abstract void resumeReceiving()
Resume 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
canSuspendReceiving()
should returnfalse
.
sendMessage
protected abstract boolean sendMessage(WebSocketMessage message) throws IOException
Send 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.
- 抛出:
IOException
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription)
- 指定者:
onSubscribe
在接口中org.reactivestreams.Subscriber<T>
onComplete
public void onComplete()
- 指定者:
onComplete
在接口中org.reactivestreams.Subscriber<T>