Package dev.adlin.vts4j
Class VTSClient
java.lang.Object
dev.adlin.vts4j.VTSClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(PluginMeta pluginMeta) Sends an authentication request with the specified plugin name and author.voidconnect()voidvoidconnectBlocking(long timeout, TimeUnit timeUnit) voidvoidvoidregisterEventListener(Listener listener) Registers event listener.sendRequest(Request request) Sends a request to the server and returns a CompletableFuture to handle the response.subscribeToEvent(String eventName) 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.subscribeToEvent(String eventName, @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.
-
Constructor Details
-
VTSClient
-
VTSClient
public VTSClient()
-
-
Method Details
-
connect
public void connect() -
connectBlocking
- Throws:
InterruptedException
-
connectBlocking
- Throws:
InterruptedException
-
disconnect
public void disconnect() -
disconnectBlocking
- Throws:
InterruptedException
-
authenticate
Sends an authentication request with the specified plugin name and author.- Parameters:
pluginMeta-
-
sendRequest
Sends a request to the server and returns a CompletableFuture to handle 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
-
subscribeToEvent
public CompletableFuture<Response> subscribeToEvent(String eventName, @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:
eventName- the name of event you need to registereventConfig- additional configuration for the event (more details at this page)- Returns:
- CompletableFuture with a response about the success of the operation
-
subscribeToEvent
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:
eventName- the name of event you need to register- Returns:
- CompletableFuture with a response about the success of the operation
-
registerEventListener
Registers event listener.The registered listener will receive notifications for events that have been subscribed to using the
subscribeToEvent(String, JsonObject)orsubscribeToEvent(String)method.- Parameters:
listener- an instance of a class implementing theListenerinterface.
-