类 AbstractWebSocketSession<T>
- java.lang.Object
- org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession<T>
- 类型参数:
T- the native delegate type
- 所有已实现的接口:
WebSocketSession
public abstract class AbstractWebSocketSession<T> extends Object implements WebSocketSession
Convenient base class forWebSocketSessionimplementations that holds common fields and exposes accessors. Also implements theWebSocketMessagefactory methods.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 限定符 构造器 说明 protectedAbstractWebSocketSession(T delegate, String id, HandshakeInfo info, DataBufferFactory bufferFactory)Create a new WebSocket session.
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 WebSocketMessagebinaryMessage(Function<DataBufferFactory,DataBuffer> payloadFactory)Factory method to create a binary WebSocketMessage using theWebSocketSession.bufferFactory()for the session.DataBufferFactorybufferFactory()Return aDataBufferFactory to create message payloads.Map<String,Object>getAttributes()Return the map with attributes associated with the WebSocket session.protected TgetDelegate()HandshakeInfogetHandshakeInfo()Return information from the handshake request.StringgetId()Return the id for the session.protected StringgetLogPrefix()WebSocketMessagepingMessage(Function<DataBufferFactory,DataBuffer> payloadFactory)Factory method to create a ping WebSocketMessage using theWebSocketSession.bufferFactory()for the session.WebSocketMessagepongMessage(Function<DataBufferFactory,DataBuffer> payloadFactory)Factory method to create a pong WebSocketMessage using theWebSocketSession.bufferFactory()for the session.abstract reactor.core.publisher.Flux<WebSocketMessage>receive()Provides access to the stream of inbound messages.abstract 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.WebSocketMessagetextMessage(String payload)Factory method to create a textWebSocketMessageusing theWebSocketSession.bufferFactory()for the session.StringtoString()从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.web.reactive.socket.WebSocketSession
close, close
构造器详细资料
AbstractWebSocketSession
protected AbstractWebSocketSession(T delegate, String id, HandshakeInfo info, DataBufferFactory bufferFactory)
Create a new WebSocket session.
方法详细资料
getDelegate
protected T getDelegate()
getId
public String getId()
从接口复制的说明:WebSocketSessionReturn the id for the session.- 指定者:
getId在接口中WebSocketSession
getHandshakeInfo
public HandshakeInfo getHandshakeInfo()
从接口复制的说明:WebSocketSessionReturn information from the handshake request.- 指定者:
getHandshakeInfo在接口中WebSocketSession
bufferFactory
public DataBufferFactory bufferFactory()
从接口复制的说明:WebSocketSessionReturn aDataBufferFactory to create message payloads.- 指定者:
bufferFactory在接口中WebSocketSession- 返回:
- the buffer factory for the session
getAttributes
public Map<String,Object> getAttributes()
从接口复制的说明:WebSocketSessionReturn the map with attributes associated with the WebSocket session.- 指定者:
getAttributes在接口中WebSocketSession- 返回:
- a Map with the session attributes (never
null)
getLogPrefix
protected String getLogPrefix()
receive
public abstract reactor.core.publisher.Flux<WebSocketMessage> receive()
从接口复制的说明:WebSocketSessionProvides access to the stream of inbound messages.This stream receives a completion or error signal when the connection is closed. In a typical
WebSocketHandlerimplementation 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
WebSocketHandlerand the reference for more details and examples of how to handle the session.- 指定者:
receive在接口中WebSocketSession
send
public abstract reactor.core.publisher.Mono<Void> send(org.reactivestreams.Publisher<WebSocketMessage> messages)
从接口复制的说明:WebSocketSessionGive 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
WebSocketHandlerand the reference for more details and examples of how to handle the session.- 指定者:
send在接口中WebSocketSession
textMessage
public WebSocketMessage textMessage(String payload)
从接口复制的说明:WebSocketSessionFactory method to create a textWebSocketMessageusing theWebSocketSession.bufferFactory()for the session.- 指定者:
textMessage在接口中WebSocketSession
binaryMessage
public WebSocketMessage binaryMessage(Function<DataBufferFactory,DataBuffer> payloadFactory)
从接口复制的说明:WebSocketSessionFactory method to create a binary WebSocketMessage using theWebSocketSession.bufferFactory()for the session.- 指定者:
binaryMessage在接口中WebSocketSession
pingMessage
public WebSocketMessage pingMessage(Function<DataBufferFactory,DataBuffer> payloadFactory)
从接口复制的说明:WebSocketSessionFactory method to create a ping WebSocketMessage using theWebSocketSession.bufferFactory()for the session.- 指定者:
pingMessage在接口中WebSocketSession
pongMessage
public WebSocketMessage pongMessage(Function<DataBufferFactory,DataBuffer> payloadFactory)
从接口复制的说明:WebSocketSessionFactory method to create a pong WebSocketMessage using theWebSocketSession.bufferFactory()for the session.- 指定者:
pongMessage在接口中WebSocketSession