Package dev.adlin.vts4j
Interface VTSClient
- All Known Implementing Classes:
VTSClientImpl
public interface VTSClient
-
Method Summary
Modifier and TypeMethodDescription@NotNull Stringauthenticate(@NotNull PluginMeta pluginMeta) Sends an authentication request with the specified plugin name and author.voidauthenticate(@NotNull PluginMeta pluginMeta, @NotNull String authToken) voidawaitConnect(long timeout, @NotNull TimeUnit timeUnit) connect()voidvoidvoidregisterEventListener(@NotNull Listener listener) Registers event listener.sendRequest(@NotNull Request request) Sends a request to the server and returns a CompletableFuture to dispatch the response.Sends a request with an eventName and config, and returns a CompletableFuture that can be used to get the server's response and determine the status of the operation.subscribe(@NotNull Class<? extends Event> eventClass, @Nullable com.google.gson.JsonObject eventConfig) Sends a request with an event type and returns a CompletableFuture that can be used to get the server's response and determine the status of the operation.unsubscribe(@NotNull Class<? extends Event> eventClass) unsubscribe(@NotNull Class<? extends Event> eventClass, @Nullable com.google.gson.JsonObject eventConfig)
-
Method Details
-
connect
VTSClient connect() -
awaitConnect
VTSClient awaitConnect() -
awaitConnect
-
disconnect
void disconnect() -
disconnectBlocking
void disconnectBlocking() -
authenticate
Sends an authentication request with the specified plugin name and author.- Parameters:
pluginMeta-- Returns:
- authentication token
-
authenticate
-
sendRequest
Sends a request to the server and returns a CompletableFuture to dispatch the response. The request is converted to JSON format and sent via a socket. The returned CompletableFuture can be used to obtain the server's response once it is available.- Parameters:
request- object to be sent to the server. This object will be serialized to JSON- Returns:
- response from the server
-
subscribe
CompletableFuture<Response> subscribe(@NotNull @NotNull Class<? extends Event> eventClass, @Nullable @Nullable com.google.gson.JsonObject eventConfig) Sends a request with an event type and returns a CompletableFuture that can be used to get the server's response and determine the status of the operation.- Parameters:
eventClass- the class of event you need to subscribeeventConfig- additional configuration for the event (more details at this page)- Returns:
- CompletableFuture with a response about the success of the operation
-
subscribe
Sends a request with an eventName and config, and returns a CompletableFuture that can be used to get the server's response and determine the status of the operation.- Parameters:
eventClass- the class of event you need to subscribe- Returns:
- CompletableFuture with a response about the success of the operation
-
unsubscribe
CompletableFuture<Response> unsubscribe(@NotNull @NotNull Class<? extends Event> eventClass, @Nullable @Nullable com.google.gson.JsonObject eventConfig) -
unsubscribe
-
registerEventListener
Registers event listener.The registered listener will receive notifications for events that have been subscribed to using the
subscribe(Class<? extends Event>, JsonObject)orsubscribe(Class<? extends Event>)method.- Parameters:
listener- an instance of a class implementing theListenerinterface.
-