Class ReactorNettyWebSocketClient
java.lang.Object
org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient
- All Implemented Interfaces:
WebSocketClient
WebSocketClient implementation for use with Reactor Netty.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient) Constructor that accepts an existingHttpClientbuilder with a defaultWebsocketClientSpec.Builder.ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient, Supplier<reactor.netty.http.client.WebsocketClientSpec.Builder> builderSupplier) Constructor that accepts an existingHttpClientbuilder and a pre-configuredWebsocketClientSpec.Builder. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void> execute(URI url, HttpHeaders requestHeaders, 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.reactor.netty.http.client.HttpClientReturn the configuredHttpClient.reactor.netty.http.client.WebsocketClientSpecBuild an instance ofWebsocketClientSpecthat reflects the current configuration.
-
Constructor Details
-
ReactorNettyWebSocketClient
public ReactorNettyWebSocketClient()Default constructor. -
ReactorNettyWebSocketClient
public ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient) Constructor that accepts an existingHttpClientbuilder with a defaultWebsocketClientSpec.Builder.- Since:
- 5.1
-
ReactorNettyWebSocketClient
public ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient, Supplier<reactor.netty.http.client.WebsocketClientSpec.Builder> builderSupplier) Constructor that accepts an existingHttpClientbuilder and a pre-configuredWebsocketClientSpec.Builder.- Since:
- 5.3
-
-
Method Details
-
getHttpClient
public reactor.netty.http.client.HttpClient getHttpClient()Return the configuredHttpClient. -
getWebsocketClientSpec
public reactor.netty.http.client.WebsocketClientSpec getWebsocketClientSpec()Build an instance ofWebsocketClientSpecthat reflects the current configuration. This can be used to check the configured parameters except for sub-protocols which depend on theWebSocketHandlerthat is used for a given upgrade.- Since:
- 5.3
-
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 requestHeaders, WebSocketHandler handler) Description copied from interface:WebSocketClientA variant ofWebSocketClient.execute(URI, WebSocketHandler)with custom headers.- Specified by:
executein interfaceWebSocketClient- Parameters:
url- the handshake urlrequestHeaders- 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.
-