Interface WebsocketRequestBuilder

All Superinterfaces:
HttpRequestBuilder<WebsocketRequestBuilder>
All Known Implementing Classes:
WebsocketRequestBuilderDefault

public interface WebsocketRequestBuilder extends HttpRequestBuilder<WebsocketRequestBuilder>
Builder to create a WebSocket requesté
  • Method Details

    • ping

      WebsocketRequestBuilder ping(int seconds)
      You can use this to configure the pings that are automatically sent to the Websocket endpoint every X seconds. WebsocketClientHandler#onConnectionClosed() will be called if the connection is closed.

      Use a value <= 0 to disable the pings.

      The automatic pings and their default interval are also configurable using: SpincastHttpClientWithWebsocketConfig#isWebsocketAutomaticPingEnabled()
      and
      SpincastHttpClientWithWebsocketConfig#getWebsocketAutomaticPingIntervalSeconds()

      Pings are enabled by default.

      Parameters:
      seconds - the interval in seconds or <= 0 to disable the pings.
    • connect

      Sends the request and establish the WebSocket connection.
      Parameters:
      handler - The handler that is responsible to handle the various WebSocket events.
      Returns:
      a writer to send WebSocket messages to the connected endpoint.
    • send

      HttpResponse send()
      Sends the request and gets the HTTP response. Does not make the actual upgrade to a WebSocket connection! Use the connect(...) method if you want the actual WebSocket connection to be made.

      This version is useful to debug the intermediate HTTP upgrade response made from the server before the actual WebSocket connection is established.

      Specified by:
      send in interface HttpRequestBuilder<WebsocketRequestBuilder>