Class VTSClientBuilder

java.lang.Object
dev.adlin.vts4j.VTSClientBuilder

public final class VTSClientBuilder extends Object
A fluent builder utility designed to orchestrate dependency injection, wire internal network handlers, and construct fully initialized VTSClient instances.

Example Usage:


 VTSClient client = VTSClientBuilder.create()
         .setAddress(URI.create("ws://127.0.0.1:8001"))
         .registerListeners(new MyEventSubscriber())
         .build();
 
  • Constructor Details

    • VTSClientBuilder

      public VTSClientBuilder()
  • Method Details

    • create

      public static @NonNull VTSClientBuilder create()
      Initializes a fresh fluent instance of VTSClientBuilder.
      Returns:
      a new builder instance
    • setAddress

      public @NonNull VTSClientBuilder setAddress(@NonNull URI address)
      Configures the target destination WebSocket address for the VTube Studio API server.
      Parameters:
      address - the remote server URI, defaults to ws://localhost:8001
      Returns:
      this builder instance for method chaining
    • registerListeners

      public @NonNull VTSClientBuilder registerListeners(@NonNull Listener... listeners)
      Registers one or more initial event listener subscribers to the client's event bus upon construction.
      Parameters:
      listeners - varargs array of custom objects implementing the Listener interface
      Returns:
      this builder instance for method chaining
    • build

      public @NonNull VTSClient build()
      Assembles, interconnects, and encapsulates all architectural layers into a ready-to-use VTSClient.

      This method automatically maps raw socket-level lifecycle hooks directly into high-level bus events (WebsocketOpenEvent, WebsocketCloseEvent, WebsocketErrorEvent) and clears the request dispatcher queue upon sudden network disconnections.

      Returns:
      a fully configured and wired VTSClient implementation instance