Top Description Fields Constructors Methods
org.springframework.web.reactive.socket.client

public Class ReactorNetty2WebSocketClient

extends Object
implements WebSocketClient
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.socket.client.WebSocketClient
Imports
java.net.URI, java.util.function.Supplier, org.apache.commons.logging.Log, .LogFactory, reactor.core.publisher.Mono, reactor.netty5.http.client.HttpClient, .WebsocketClientSpec, reactor.netty5.http.websocket.WebsocketInbound, org.springframework.core.io.buffer.Netty5DataBufferFactory, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils, org.springframework.web.reactive.socket.HandshakeInfo, .WebSocketHandler, .WebSocketSession, org.springframework.web.reactive.socket.adapter.ReactorNetty2WebSocketSession

WebSocketClient implementation for use with Reactor Netty for Netty 5.

This class is based on ReactorNettyWebSocketClient.

Author
Violeta Georgieva
Since
6.0

Field Summary

Modifier and TypeField and Description
private Boolean
private final HttpClient
private static final Log
private final Supplier<WebsocketClientSpec.Builder>

Constructor Summary

AccessConstructor and Description
public
ReactorNetty2WebSocketClient()

Default constructor.

public
ReactorNetty2WebSocketClient(HttpClient httpClient)

Constructor that accepts an existing HttpClient builder with a default WebsocketClientSpec.Builder.

public
ReactorNetty2WebSocketClient(HttpClient httpClient, Supplier<WebsocketClientSpec.Builder> builderSupplier)

Constructor that accepts an existing HttpClient builder and a pre-configured WebsocketClientSpec.Builder.

Method Summary

Modifier and TypeMethod and Description
private WebsocketClientSpec
buildSpec(String protocols)

public Mono<Void>
execute(URI
the handshake url
url
,
WebSocketHandler
the handler of the WebSocket session
handler
)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

public Mono<Void>
execute(URI
the handshake url
url
,
HttpHeaders
custom headers for the handshake request
requestHeaders
,
WebSocketHandler
the handler of the WebSocket session
handler
)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

A variant of execute(URI, WebSocketHandler) with custom headers.

public HttpClient
getHttpClient()

Return the configured HttpClient.

public WebsocketClientSpec
getWebsocketClientSpec()

Build an instance of WebsocketClientSpec that reflects the current configuration.

private void
setNettyHeaders(HttpHeaders httpHeaders, HttpHeaders nettyHeaders)

private HttpHeaders
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlePingback to summary
private Boolean handlePing
Annotations
@Nullable
httpClientback to summary
private final HttpClient httpClient
loggerback to summary
private static final Log logger
specBuilderSupplierback to summary
private final Supplier<WebsocketClientSpec.Builder> specBuilderSupplier

Constructor Detail

ReactorNetty2WebSocketClientback to summary
public ReactorNetty2WebSocketClient()

Default constructor.

ReactorNetty2WebSocketClientback to summary
public ReactorNetty2WebSocketClient(HttpClient httpClient)

Constructor that accepts an existing HttpClient builder with a default WebsocketClientSpec.Builder.

Since
5.1
ReactorNetty2WebSocketClientback to summary
public ReactorNetty2WebSocketClient(HttpClient httpClient, Supplier<WebsocketClientSpec.Builder> builderSupplier)

Constructor that accepts an existing HttpClient builder and a pre-configured WebsocketClientSpec.Builder.

Method Detail

buildSpecback to summary
private WebsocketClientSpec buildSpec(String protocols)
executeback to summary
public Mono<Void> execute(URI url, WebSocketHandler handler)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Doc from org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

Parameters
url:URI

the handshake url

handler:WebSocketHandler

the handler of the WebSocket session

Returns:Mono<Void>

completion Mono<Void> to indicate the outcome of the WebSocket session handling.

Annotations
@Override
executeback to summary
public Mono<Void> execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Doc from org.springframework.web.reactive.socket.client.WebSocketClient.execute.

A variant of execute(URI, WebSocketHandler) with custom headers.

Parameters
url:URI

the handshake url

requestHeaders:HttpHeaders

custom headers for the handshake request

handler:WebSocketHandler

the handler of the WebSocket session

Returns:Mono<Void>

completion Mono<Void> to indicate the outcome of the WebSocket session handling.

Annotations
@Override
getHttpClientback to summary
public HttpClient getHttpClient()

Return the configured HttpClient.

getWebsocketClientSpecback to summary
public WebsocketClientSpec getWebsocketClientSpec()

Build an instance of WebsocketClientSpec that reflects the current configuration. This can be used to check the configured parameters except for sub-protocols which depend on the WebSocketHandler that is used for a given upgrade.

setNettyHeadersback to summary
private void setNettyHeaders(HttpHeaders httpHeaders, HttpHeaders nettyHeaders)
toHttpHeadersback to summary
private HttpHeaders toHttpHeaders(WebsocketInbound inbound)