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
-