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 Jakarta webSocket API.
Since:
5.0
Author:
Violeta Georgieva, Rossen Stoyanchev
See Also:
  • Constructor Details

    • StandardwebSocketClient

      public StandardwebSocketClient()
      Default constructor that calls ContainerProvider.getwebSocketContainer() to obtain a (new) webSocketContainer instance.
    • StandardwebSocketClient

      public StandardwebSocketClient(jakarta.websocket.webSocketContainer webSocketContainer)
      Constructor accepting an existing webSocketContainer instance.
      Parameters:
      webSocketContainer - a web socket container
  • Method Details

    • getwebSocketContainer

      public jakarta.websocket.webSocketContainer getwebSocketContainer()
      Return the configured webSocketContainer 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 interface webSocketClient
      Parameters:
      url - the handshake url
      handler - 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 of webSocketClient.execute(URI, webSocketHandler) with custom headers.
      Specified by:
      execute in interface webSocketClient
      Parameters:
      url - the handshake url
      headers - custom headers for the handshake request
      handler - 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 the StandardwebSocketSession for the given Jakarta webSocket Session.
      See Also:
    • bufferFactory

    • createEndpointConfig

      protected jakarta.websocket.ClientEndpointConfig createEndpointConfig(jakarta.websocket.ClientEndpointConfig.Configurator configurator, List<String> subProtocols)
      Create the ClientEndpointConfig for the given configurator. Can be overridden to add extensions or an SSL context.
      Parameters:
      configurator - the configurator to apply
      subProtocols - the preferred sub-protocols
      Since:
      6.1.3