Package dev.adlin.vts4j
Class VTSClientBuilder
java.lang.Object
dev.adlin.vts4j.VTSClientBuilder
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull VTSClientbuild()Assembles, interconnects, and encapsulates all architectural layers into a ready-to-useVTSClient.static @NonNull VTSClientBuildercreate()Initializes a fresh fluent instance ofVTSClientBuilder.@NonNull VTSClientBuilderregisterListeners(@NonNull Listener... listeners) Registers one or more initial event listener subscribers to the client's event bus upon construction.@NonNull VTSClientBuildersetAddress(@NonNull URI address) Configures the target destination WebSocket address for the VTube Studio API server.
-
Constructor Details
-
VTSClientBuilder
public VTSClientBuilder()
-
-
Method Details
-
create
Initializes a fresh fluent instance ofVTSClientBuilder.- Returns:
- a new builder instance
-
setAddress
Configures the target destination WebSocket address for the VTube Studio API server.- Parameters:
address- the remote serverURI, defaults tows://localhost:8001- Returns:
- this builder instance for method chaining
-
registerListeners
Registers one or more initial event listener subscribers to the client's event bus upon construction.- Parameters:
listeners- varargs array of custom objects implementing theListenerinterface- Returns:
- this builder instance for method chaining
-
build
Assembles, interconnects, and encapsulates all architectural layers into a ready-to-useVTSClient.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
VTSClientimplementation instance
-