Package dev.adlin.vts4j
Class VTSClientImpl
java.lang.Object
dev.adlin.vts4j.VTSClientImpl
- All Implemented Interfaces:
VTSClient
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedVTSClientImpl(@NotNull NetworkClient networkClient, @NotNull EventHandler eventHandler, @NotNull RequestDispatcher requestDispatcher) -
Method Summary
Modifier and TypeMethodDescription@NotNull Stringauthenticate(@NonNull PluginMeta pluginMeta) Sends an authentication request with the specified plugin name and author.voidauthenticate(@NonNull PluginMeta pluginMeta, @NonNull String authToken) voidawaitConnect(long timeout, @NonNull TimeUnit timeUnit) connect()voidvoidvoidregisterEventListener(@NonNull Listener listener) Registers event listener.sendRequest(@NonNull 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)
-
Constructor Details
-
VTSClientImpl
protected VTSClientImpl(@NotNull @NotNull NetworkClient networkClient, @NotNull @NotNull EventHandler eventHandler, @NotNull @NotNull RequestDispatcher requestDispatcher)
-
-
Method Details
-
connect
-
awaitConnect
- Specified by:
awaitConnectin interfaceVTSClient
-
awaitConnect
- Specified by:
awaitConnectin interfaceVTSClient
-
disconnect
public void disconnect()- Specified by:
disconnectin interfaceVTSClient
-
disconnectBlocking
public void disconnectBlocking()- Specified by:
disconnectBlockingin interfaceVTSClient
-
authenticate
Description copied from interface:VTSClientSends an authentication request with the specified plugin name and author.- Specified by:
authenticatein interfaceVTSClient- Parameters:
pluginMeta-- Returns:
- authentication token
-
authenticate
- Specified by:
authenticatein interfaceVTSClient
-
sendRequest
Description copied from interface:VTSClientSends 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.- Specified by:
sendRequestin interfaceVTSClient- Parameters:
request- object to be sent to the server. This object will be serialized to JSON- Returns:
- response from the server
-
subscribe
public CompletableFuture<Response> subscribe(@NotNull @NotNull Class<? extends Event> eventClass, @Nullable @Nullable com.google.gson.JsonObject eventConfig) Description copied from interface:VTSClientSends 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. -
subscribe
Description copied from interface:VTSClientSends 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. -
unsubscribe
public CompletableFuture<Response> unsubscribe(@NotNull @NotNull Class<? extends Event> eventClass, @Nullable @Nullable com.google.gson.JsonObject eventConfig) - Specified by:
unsubscribein interfaceVTSClient
-
unsubscribe
- Specified by:
unsubscribein interfaceVTSClient
-
registerEventListener
Description copied from interface:VTSClientRegisters event listener.The registered listener will receive notifications for events that have been subscribed to using the
VTSClient.subscribe(Class<? extends Event>, JsonObject)orVTSClient.subscribe(Class<? extends Event>)method.- Specified by:
registerEventListenerin interfaceVTSClient- Parameters:
listener- an instance of a class implementing theListenerinterface.
-