Package dev.adlin.vts4j
Interface VTSClient
- All Known Implementing Classes:
VTSClientImpl
public interface VTSClient
The primary high-level client interface for interacting with the VTube Studio Public API.
Provides full control over the connection lifecycle, token authentication, request dispatching, and event subscription management workflows.
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NonNull CompletableFuture<String> authenticate(@NonNull PluginMeta pluginMeta) Requests a brand new authentication token from VTube Studio for the specified plugin metadata.voidauthenticate(@NonNull PluginMeta pluginMeta, @NonNull String authenticationToken) Authenticates the plugin session instantly using a previously saved existing authentication token.Establishes a synchronous connection to the remote server, blocking the calling thread indefinitely until the connection handshake completes or fails.awaitConnect(long timeout, @NonNull TimeUnit timeUnit) Establishes a synchronous connection to the remote server, blocking the calling thread up to the specified timeout interval.voidSynchronously tears down the active socket session, blocking the calling thread until the close handshake is acknowledged.connect()Initiates a non-blocking background connection routine to the remote VTube Studio server.voidInitiates an asynchronous, non-blocking disconnection routine to close the socket session.voidregisterEventListener(@NonNull Listener listener) Registers an event listener object within the client's internal event bus.sendRequest(@NonNull Request request) Serializes and dispatches an asynchronous request packet to the server over the active socket session.Subscribes the current plugin session to a specific system event type using default configurations.subscribe(@NonNull Class<? extends Event> eventClass, @NonNull com.google.gson.JsonObject eventConfig) Subscribes the current plugin session to a specific system event type using extended configuration arguments.unsubscribe(@NonNull Class<? extends Event> eventClass) Unsubscribes the current plugin session from all instances of the specified system event type.unsubscribe(@NonNull Class<? extends Event> eventClass, @NonNull com.google.gson.JsonObject eventConfig) Unsubscribes the current plugin session from a specific system event matching the provided configuration filters.
-
Method Details
-
connect
VTSClient connect()Initiates a non-blocking background connection routine to the remote VTube Studio server.- Returns:
- this client instance for fluent method chaining
-
awaitConnect
VTSClient awaitConnect()Establishes a synchronous connection to the remote server, blocking the calling thread indefinitely until the connection handshake completes or fails.- Returns:
- this client instance for fluent method chaining
-
awaitConnect
Establishes a synchronous connection to the remote server, blocking the calling thread up to the specified timeout interval.- Parameters:
timeout- the maximum duration to wait for a connection handshaketimeUnit- the time unit of the timeout argument- Returns:
- this client instance for fluent method chaining
-
disconnect
void disconnect()Initiates an asynchronous, non-blocking disconnection routine to close the socket session. -
awaitDisconnect
void awaitDisconnect()Synchronously tears down the active socket session, blocking the calling thread until the close handshake is acknowledged. -
authenticate
Requests a brand new authentication token from VTube Studio for the specified plugin metadata.This will trigger a pop-up confirmation window inside the VTube Studio UI for the end-user.
- Parameters:
pluginMeta- the metadata configuration of the plugin requesting access- Returns:
- a
CompletableFuturethat resolves to the newly issued unique authentication token string
-
authenticate
Authenticates the plugin session instantly using a previously saved existing authentication token.- Parameters:
pluginMeta- the metadata configuration of the pluginauthenticationToken- the pre-issued token string to authenticate with
-
sendRequest
Serializes and dispatches an asynchronous request packet to the server over the active socket session.- Parameters:
request- the request packet structure to be transmitted- Returns:
- a
CompletableFuturecontaining the server's asynchronousResponsepackage
-
subscribe
CompletableFuture<Response> subscribe(@NonNull Class<? extends Event> eventClass, @NonNull com.google.gson.JsonObject eventConfig) Subscribes the current plugin session to a specific system event type using extended configuration arguments.Re-subscribing to an already active event type will seamlessly overwrite its previous parameters. For details regarding available event names and payloads, see the VTube Studio Events Guide.
- Parameters:
eventClass- the class type of the targetEventto subscribe toeventConfig- custom JSON configuration properties and filters specific to the event type- Returns:
- a
CompletableFuturecontaining the server response acknowledgment indicating operation status
-
subscribe
Subscribes the current plugin session to a specific system event type using default configurations.- Parameters:
eventClass- the class type of the targetEventto subscribe to- Returns:
- a
CompletableFuturecontaining the server response acknowledgment indicating operation status
-
unsubscribe
CompletableFuture<Response> unsubscribe(@NonNull Class<? extends Event> eventClass, @NonNull com.google.gson.JsonObject eventConfig) Unsubscribes the current plugin session from a specific system event matching the provided configuration filters.- Parameters:
eventClass- the class type of the targetEventto unsubscribe fromeventConfig- custom JSON configuration parameters to match for removal- Returns:
- a
CompletableFuturecontaining the server response acknowledgment indicating operation status
-
unsubscribe
Unsubscribes the current plugin session from all instances of the specified system event type.- Parameters:
eventClass- the class type of the targetEventto unsubscribe from- Returns:
- a
CompletableFuturecontaining the server response acknowledgment indicating operation status
-
registerEventListener
Registers an event listener object within the client's internal event bus.The registered instance will intercept notifications for any system events that have been activated using the
subscribemethods.- Parameters:
listener- an instance of a custom class implementing the markerListenerinterface
-