Interface WebSocketClient

All Superinterfaces:
Measured

public interface WebSocketClient extends Measured
An asynchronous WebSocket client.

It allows you to open WebSockets to servers.

Author:
Tim Fox
  • Method Details

    • webSocket

      ClientWebSocket webSocket()
      Create a WebSocket that is not yet connected to the server.
      Returns:
      the client WebSocket
    • connect

      default Future<WebSocket> connect(int port, String host, String requestURI)
      Connect a WebSocket to the specified port, host and relative request URI.
      Parameters:
      port - the port
      host - the host
      requestURI - the relative URI
      Returns:
      a future notified when the WebSocket when connected
    • connect

      default Future<WebSocket> connect(String host, String requestURI)
      Connect a WebSocket to the default client port and specified host and relative request URI.
      Parameters:
      host - the host
      requestURI - the relative URI
      Returns:
      a future notified when the WebSocket when connected
    • connect

      default Future<WebSocket> connect(String requestURI)
      Connect a WebSocket to the default client port, default client host and specified, relative request URI.
      Parameters:
      requestURI - the relative URI
      Returns:
      a future notified when the WebSocket when connected
    • connect

      Connect a WebSocket with the specified options.
      Parameters:
      options - the request options
      Returns:
      a future notified when the WebSocket when connected
    • shutdown

      default Future<Void> shutdown()
      Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).
      Returns:
      a future completed when shutdown has completed
    • close

      default Future<Void> close()
      Close immediately (shutdown(0, TimeUnit.SECONDS).
      Returns:
      a future notified when the client is closed
    • updateSSLOptions

      default Future<Boolean> updateSSLOptions(ClientSSLOptions options)
      Update the client with new SSL options, the update happens if the options object is valid and different from the existing options object.
      Parameters:
      options - the new SSL options
      Returns:
      a future signaling the update success
    • updateSSLOptions

      Future<Boolean> updateSSLOptions(ClientSSLOptions options, boolean force)

      Update the client with new SSL options, the update happens if the options object is valid and different from the existing options object.

      The options object is compared using its equals method against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, setting force to true forces the update.

      Parameters:
      options - the new SSL options
      force - force the update when options are equals
      Returns:
      a future signaling the update success
    • shutdown

      default Future<Void> shutdown(long timeout, TimeUnit unit)
    • shutdown

      Future<Void> shutdown(Duration timeout)
      Initiate the client shutdown sequence.
      Parameters:
      timeout - the amount of time after which all resources are forcibly closed
      Returns:
      a future notified when the client is closed