Class MagicWebSocketClient

java.lang.Object
dev.ua.theroer.magicutils.http.MagicWebSocketClient
All Implemented Interfaces:
AutoCloseable

public final class MagicWebSocketClient extends Object implements AutoCloseable
MagicUtils WebSocket client with config defaults and logging.
  • Method Details

    • builder

      public static MagicWebSocketClient.Builder builder(Platform platform, ConfigManager configManager)
      Creates a builder that loads configuration from the provided manager.
      Parameters:
      platform - platform used for logging
      configManager - configuration manager used to register HttpClientConfig
      Returns:
      a new builder instance
    • builder

      public static MagicWebSocketClient.Builder builder(Platform platform)
      Creates a builder without auto-loading configuration.
      Parameters:
      platform - platform used for logging
      Returns:
      a new builder instance
    • connectAsync

      public CompletableFuture<WebSocket> connectAsync(String path, WebSocket.Listener listener)
      Connects to a WebSocket endpoint asynchronously.
      Parameters:
      path - absolute URL or a path resolved against base URL
      listener - websocket listener
      Returns:
      future with WebSocket
    • connect

      public WebSocket connect(String path, WebSocket.Listener listener) throws IOException, InterruptedException
      Connects to a WebSocket endpoint (blocking).
      Parameters:
      path - absolute URL or a path resolved against base URL
      listener - websocket listener
      Returns:
      connected WebSocket
      Throws:
      IOException - if connection fails
      InterruptedException - if thread interrupted
    • connectSmart

      public CompletableFuture<WebSocket> connectSmart(String path, WebSocket.Listener listener)
      Connects to a WebSocket endpoint, switching to async on blocking-sensitive threads.
      Parameters:
      path - absolute URL or a path resolved against base URL
      listener - websocket listener
      Returns:
      future with WebSocket
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable