Class VTSClient

java.lang.Object
dev.adlin.vts4j.VTSClient

public class VTSClient extends Object
  • Constructor Details

    • VTSClient

      public VTSClient(URI vtsAddress)
    • VTSClient

      public VTSClient()
  • Method Details

    • connect

      public void connect()
    • connectBlocking

      public void connectBlocking() throws InterruptedException
      Throws:
      InterruptedException
    • connectBlocking

      public void connectBlocking(long timeout, TimeUnit timeUnit) throws InterruptedException
      Throws:
      InterruptedException
    • disconnect

      public void disconnect()
    • disconnectBlocking

      public void disconnectBlocking() throws InterruptedException
      Throws:
      InterruptedException
    • authenticate

      public void authenticate(PluginMeta pluginMeta)
      Sends an authentication request with the specified plugin name and author.
      Parameters:
      pluginMeta -
    • sendRequest

      public CompletableFuture<Response> sendRequest(Request request)
      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 register
      eventConfig - additional configuration for the event (more details at this page)
      Returns:
      CompletableFuture with a response about the success of the operation
    • subscribeToEvent

      public CompletableFuture<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.
      Parameters:
      eventName - the name of event you need to register
      Returns:
      CompletableFuture with a response about the success of the operation
    • registerEventListener

      public void registerEventListener(Listener listener)
      Registers event listener.

      The registered listener will receive notifications for events that have been subscribed to using the subscribeToEvent(String, JsonObject) or subscribeToEvent(String) method.

      Parameters:
      listener - an instance of a class implementing the Listener interface.