T
- the native delegate typepublic abstract class AbstractWebSocketSession<T> extends java.lang.Object implements WebSocketSession
WebSocketSession
implementations that
holds common fields and exposes accessors. Also implements the
WebSocketMessage
factory methods.Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
attributes |
private DataBufferFactory |
bufferFactory |
private T |
delegate |
private HandshakeInfo |
handshakeInfo |
private java.lang.String |
id |
protected Log |
logger |
private java.lang.String |
logPrefix |
Modifier | Constructor and Description |
---|---|
protected |
AbstractWebSocketSession(T delegate,
java.lang.String id,
HandshakeInfo info,
DataBufferFactory bufferFactory)
Create a new WebSocket session.
|
Modifier and Type | Method and Description |
---|---|
WebSocketMessage |
binaryMessage(java.util.function.Function<DataBufferFactory,DataBuffer> payloadFactory)
Factory method to create a binary WebSocketMessage using the
WebSocketSession.bufferFactory() for the session. |
DataBufferFactory |
bufferFactory()
Return a
DataBuffer Factory to create message payloads. |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Return the map with attributes associated with the WebSocket session.
|
protected T |
getDelegate() |
HandshakeInfo |
getHandshakeInfo()
Return information from the handshake request.
|
java.lang.String |
getId()
Return the id for the session.
|
protected java.lang.String |
getLogPrefix() |
private static java.lang.String |
initLogPrefix(HandshakeInfo info,
java.lang.String id) |
WebSocketMessage |
pingMessage(java.util.function.Function<DataBufferFactory,DataBuffer> payloadFactory)
Factory method to create a ping WebSocketMessage using the
WebSocketSession.bufferFactory() for the session. |
WebSocketMessage |
pongMessage(java.util.function.Function<DataBufferFactory,DataBuffer> payloadFactory)
Factory method to create a pong WebSocketMessage using the
WebSocketSession.bufferFactory() for the session. |
abstract <any> |
receive()
Provides access to the stream of inbound messages.
|
abstract <any> |
send(<any> 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. |
WebSocketMessage |
textMessage(java.lang.String payload)
Factory method to create a text
WebSocketMessage using the
WebSocketSession.bufferFactory() for the session. |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, close
protected final Log logger
private final T delegate
private final java.lang.String id
private final HandshakeInfo handshakeInfo
private final DataBufferFactory bufferFactory
private final java.util.Map<java.lang.String,java.lang.Object> attributes
private final java.lang.String logPrefix
protected AbstractWebSocketSession(T delegate, java.lang.String id, HandshakeInfo info, DataBufferFactory bufferFactory)
private static java.lang.String initLogPrefix(HandshakeInfo info, java.lang.String id)
protected T getDelegate()
public java.lang.String getId()
WebSocketSession
getId
in interface WebSocketSession
public HandshakeInfo getHandshakeInfo()
WebSocketSession
getHandshakeInfo
in interface WebSocketSession
public DataBufferFactory bufferFactory()
WebSocketSession
DataBuffer
Factory to create message payloads.bufferFactory
in interface WebSocketSession
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
WebSocketSession
getAttributes
in interface WebSocketSession
null
)protected java.lang.String getLogPrefix()
public abstract <any> receive()
WebSocketSession
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
in interface WebSocketSession
public abstract <any> send(<any> messages)
WebSocketSession
Mono<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 WebSocketSession
public WebSocketMessage textMessage(java.lang.String payload)
WebSocketSession
WebSocketMessage
using the
WebSocketSession.bufferFactory()
for the session.textMessage
in interface WebSocketSession
public WebSocketMessage binaryMessage(java.util.function.Function<DataBufferFactory,DataBuffer> payloadFactory)
WebSocketSession
WebSocketSession.bufferFactory()
for the session.binaryMessage
in interface WebSocketSession
public WebSocketMessage pingMessage(java.util.function.Function<DataBufferFactory,DataBuffer> payloadFactory)
WebSocketSession
WebSocketSession.bufferFactory()
for the session.pingMessage
in interface WebSocketSession
public WebSocketMessage pongMessage(java.util.function.Function<DataBufferFactory,DataBuffer> payloadFactory)
WebSocketSession
WebSocketSession.bufferFactory()
for the session.pongMessage
in interface WebSocketSession
public java.lang.String toString()
toString
in class java.lang.Object