Class VTSClientImpl

java.lang.Object
dev.adlin.vts4j.VTSClientImpl
All Implemented Interfaces:
VTSClient

public class VTSClientImpl extends Object implements VTSClient
  • Constructor Details

  • Method Details

    • connect

      public VTSClient connect()
      Specified by:
      connect in interface VTSClient
    • awaitConnect

      public VTSClient awaitConnect()
      Specified by:
      awaitConnect in interface VTSClient
    • awaitConnect

      public void awaitConnect(long timeout, @NonNull TimeUnit timeUnit)
      Specified by:
      awaitConnect in interface VTSClient
    • disconnect

      public void disconnect()
      Specified by:
      disconnect in interface VTSClient
    • disconnectBlocking

      public void disconnectBlocking()
      Specified by:
      disconnectBlocking in interface VTSClient
    • authenticate

      @NotNull public @NotNull String authenticate(@NonNull PluginMeta pluginMeta)
      Description copied from interface: VTSClient
      Sends an authentication request with the specified plugin name and author.
      Specified by:
      authenticate in interface VTSClient
      Parameters:
      pluginMeta -
      Returns:
      authentication token
    • authenticate

      public void authenticate(@NonNull PluginMeta pluginMeta, @NonNull String authToken)
      Specified by:
      authenticate in interface VTSClient
    • sendRequest

      public CompletableFuture<Response> sendRequest(@NonNull Request request)
      Description copied from interface: VTSClient
      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.
      Specified by:
      sendRequest in interface VTSClient
      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: VTSClient
      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.
      Specified by:
      subscribe in interface VTSClient
      Parameters:
      eventClass - the class of event you need to subscribe
      eventConfig - additional configuration for the event (more details at this page)
      Returns:
      CompletableFuture with a response about the success of the operation
    • subscribe

      public CompletableFuture<Response> subscribe(@NotNull @NotNull Class<? extends Event> eventClass)
      Description copied from interface: VTSClient
      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.
      Specified by:
      subscribe in interface VTSClient
      Parameters:
      eventClass - the class of event you need to subscribe
      Returns:
      CompletableFuture with a response about the success of the operation
    • unsubscribe

      public CompletableFuture<Response> unsubscribe(@NotNull @NotNull Class<? extends Event> eventClass, @Nullable @Nullable com.google.gson.JsonObject eventConfig)
      Specified by:
      unsubscribe in interface VTSClient
    • unsubscribe

      public CompletableFuture<Response> unsubscribe(@NotNull @NotNull Class<? extends Event> eventClass)
      Specified by:
      unsubscribe in interface VTSClient
    • registerEventListener

      public void registerEventListener(@NonNull Listener listener)
      Description copied from interface: VTSClient
      Registers event listener.

      The registered listener will receive notifications for events that have been subscribed to using the VTSClient.subscribe(Class<? extends Event>, JsonObject) or VTSClient.subscribe(Class<? extends Event>) method.

      Specified by:
      registerEventListener in interface VTSClient
      Parameters:
      listener - an instance of a class implementing the Listener interface.