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(WebSocketContainer webSocketContainer)
      Constructor accepting an existing WebSocketContainer instance.
      Parameters:
      webSocketContainer - a web socket container
  • Method Details

    • getWebSocketContainer

      public 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, org.springframework.http.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(Session session, HandshakeInfo info, reactor.core.publisher.Sinks.Empty<Void> completionSink)
    • bufferFactory

      protected org.springframework.core.io.buffer.DataBufferFactory bufferFactory()