Interface WebSocketSession
- All Known Implementing Classes:
- AbstractListenerWebSocketSession,- AbstractWebSocketSession,- JettyWebSocketSession,- Netty5WebSocketSessionSupport,- NettyWebSocketSessionSupport,- ReactorNetty2WebSocketSession,- ReactorNettyWebSocketSession,- StandardWebSocketSession,- TomcatWebSocketSession,- UndertowWebSocketSession
public interface WebSocketSession
Represents a WebSocket session.
 
Use session.receive() to compose on
 the inbound message stream, and session.send(publisher) to provide the outbound message stream.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev
- 
Method SummaryModifier and TypeMethodDescriptionbinaryMessage(Function<DataBufferFactory, DataBuffer> payloadFactory) Factory method to create a binary WebSocketMessage using thebufferFactory()for the session.Return aDataBufferFactory to create message payloads.default reactor.core.publisher.Mono<Void>close()Close the WebSocket session withCloseStatus.NORMAL.reactor.core.publisher.Mono<Void>close(CloseStatus status) Close the WebSocket session with the given status.reactor.core.publisher.Mono<CloseStatus>Provides access to theCloseStatuswith which the session is closed either locally or remotely, or completes empty if the session ended without a status.Return the map with attributes associated with the WebSocket session.Return information from the handshake request.getId()Return the id for the session.booleanisOpen()Whether the underlying connection is open.pingMessage(Function<DataBufferFactory, DataBuffer> payloadFactory) Factory method to create a ping WebSocketMessage using thebufferFactory()for the session.pongMessage(Function<DataBufferFactory, DataBuffer> payloadFactory) Factory method to create a pong WebSocketMessage using thebufferFactory()for the session.reactor.core.publisher.Flux<WebSocketMessage>receive()Provides access to the stream of inbound messages.reactor.core.publisher.Mono<Void>send(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.textMessage(String payload) Factory method to create a textWebSocketMessageusing thebufferFactory()for the session.
- 
Method Details- 
getIdString getId()Return the id for the session.
- 
getHandshakeInfoHandshakeInfo getHandshakeInfo()Return information from the handshake request.
- 
bufferFactoryDataBufferFactory bufferFactory()Return aDataBufferFactory to create message payloads.- Returns:
- the buffer factory for the session
 
- 
getAttributesReturn the map with attributes associated with the WebSocket session.- Returns:
- a Map with the session attributes (never null)
- Since:
- 5.1
 
- 
receivereactor.core.publisher.Flux<WebSocketMessage> receive()Provides 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.
- 
sendGive 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.
- 
isOpenboolean isOpen()Whether the underlying connection is open.- Since:
- 5.3.1
 
- 
closeClose the WebSocket session withCloseStatus.NORMAL.
- 
closeClose the WebSocket session with the given status.- Parameters:
- status- the close status
 
- 
closeStatusreactor.core.publisher.Mono<CloseStatus> closeStatus()Provides access to theCloseStatuswith which the session is closed either locally or remotely, or completes empty if the session ended without a status.- Since:
- 5.3
 
- 
textMessageFactory method to create a textWebSocketMessageusing thebufferFactory()for the session.
- 
binaryMessageFactory method to create a binary WebSocketMessage using thebufferFactory()for the session.
- 
pingMessageFactory method to create a ping WebSocketMessage using thebufferFactory()for the session.
- 
pongMessageFactory method to create a pong WebSocketMessage using thebufferFactory()for the session.
 
-