Class StandardWebSocketClient
- java.lang.Object
- org.springframework.web.reactive.socket.client.StandardWebSocketClient
- All Implemented Interfaces:
WebSocketClient
- Direct Known Subclasses:
TomcatWebSocketClient
public class StandardWebSocketClient extends Object implements WebSocketClient
WebSocketClient
implementation for use with the Java WebSocket API.- Since:
- 5.0
- Author:
- Violeta Georgieva, Rossen Stoyanchev
- See Also:
- https://www.jcp.org/en/jsr/detail?id=356
Constructor Summary
Constructors Constructor Description StandardWebSocketClient()
Default constructor that callsContainerProvider.getWebSocketContainer()
to obtain a (new)WebSocketContainer
instance.StandardWebSocketClient(WebSocketContainer webSocketContainer)
Constructor accepting an existingWebSocketContainer
instance.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DataBufferFactory
bufferFactory()
protected StandardWebSocketSession
createWebSocketSession(Session session, HandshakeInfo info, reactor.core.publisher.MonoProcessor<Void> completion)
reactor.core.publisher.Mono<Void>
execute(URI url, HttpHeaders headers, WebSocketHandler handler)
A variant ofWebSocketClient.execute(URI, WebSocketHandler)
with custom headers.reactor.core.publisher.Mono<Void>
execute(URI url, WebSocketHandler handler)
Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.WebSocketContainer
getWebSocketContainer()
Return the configuredWebSocketContainer
to use.
Constructor Detail
StandardWebSocketClient
public StandardWebSocketClient()
Default constructor that callsContainerProvider.getWebSocketContainer()
to obtain a (new)WebSocketContainer
instance.
StandardWebSocketClient
public StandardWebSocketClient(WebSocketContainer webSocketContainer)
Constructor accepting an existingWebSocketContainer
instance.- Parameters:
webSocketContainer
- a web socket container
Method Detail
getWebSocketContainer
public WebSocketContainer getWebSocketContainer()
Return the configuredWebSocketContainer
to use.
execute
public reactor.core.publisher.Mono<Void> execute(URI url, WebSocketHandler handler)
Description copied from interface:WebSocketClient
Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.- Specified by:
execute
in interfaceWebSocketClient
- Parameters:
url
- the handshake urlhandler
- the handler of the WebSocket session- Returns:
- completion
Mono<Void>
to indicate the outcome of the WebSocket session handling.
execute
public reactor.core.publisher.Mono<Void> execute(URI url, HttpHeaders headers, WebSocketHandler handler)
Description copied from interface:WebSocketClient
A variant ofWebSocketClient.execute(URI, WebSocketHandler)
with custom headers.- Specified by:
execute
in interfaceWebSocketClient
- Parameters:
url
- the handshake urlheaders
- custom headers for the handshake requesthandler
- the handler of the WebSocket session- Returns:
- completion
Mono<Void>
to indicate the outcome of the WebSocket session handling.
createWebSocketSession
protected StandardWebSocketSession createWebSocketSession(Session session, HandshakeInfo info, reactor.core.publisher.MonoProcessor<Void> completion)
bufferFactory
protected DataBufferFactory bufferFactory()