Class StandardWebSocketClient
java.lang.Object
org.springframework.web.reactive.socket.client.StandardWebSocketClient
- All Implemented Interfaces:
WebSocketClient
- Direct Known Subclasses:
TomcatWebSocketClient
WebSocketClient implementation for use with the Jakarta WebSocket API.- Since:
- 5.0
- Author:
- Violeta Georgieva, Rossen Stoyanchev
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor that callsContainerProvider.getWebSocketContainer()to obtain a (new)WebSocketContainerinstance.StandardWebSocketClient(jakarta.websocket.WebSocketContainer webSocketContainer) Constructor accepting an existingWebSocketContainerinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected DataBufferFactoryReturn theDataBufferFactoryto use.protected jakarta.websocket.ClientEndpointConfigcreateEndpointConfig(jakarta.websocket.ClientEndpointConfig.Configurator configurator, List<String> subProtocols) Create theClientEndpointConfigfor the given configurator.protected StandardWebSocketSessioncreateWebSocketSession(jakarta.websocket.Session session, HandshakeInfo info, reactor.core.publisher.Sinks.Empty<Void> completionSink) Create theStandardWebSocketSessionfor the given Jakarta WebSocket Session.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.jakarta.websocket.WebSocketContainerReturn the configuredWebSocketContainerto use.
-
Constructor Details
-
StandardWebSocketClient
public StandardWebSocketClient()Default constructor that callsContainerProvider.getWebSocketContainer()to obtain a (new)WebSocketContainerinstance. -
StandardWebSocketClient
public StandardWebSocketClient(jakarta.websocket.WebSocketContainer webSocketContainer) Constructor accepting an existingWebSocketContainerinstance.- Parameters:
webSocketContainer- a web socket container
-
-
Method Details
-
getWebSocketContainer
public jakarta.websocket.WebSocketContainer getWebSocketContainer()Return the configuredWebSocketContainerto use. -
execute
Description copied from interface:WebSocketClientExecute a handshake request to the given url and handle the resulting WebSocket session with the given handler.- Specified by:
executein 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:WebSocketClientA variant ofWebSocketClient.execute(URI, WebSocketHandler)with custom headers.- Specified by:
executein 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(jakarta.websocket.Session session, HandshakeInfo info, reactor.core.publisher.Sinks.Empty<Void> completionSink) Create theStandardWebSocketSessionfor the given Jakarta WebSocket Session.- See Also:
-
bufferFactory
-
createEndpointConfig
protected jakarta.websocket.ClientEndpointConfig createEndpointConfig(jakarta.websocket.ClientEndpointConfig.Configurator configurator, List<String> subProtocols) Create theClientEndpointConfigfor the given configurator. Can be overridden to add extensions or an SSL context.- Parameters:
configurator- the configurator to applysubProtocols- the preferred sub-protocols- Since:
- 6.1.3
-