Class RequestDispatcher

java.lang.Object
dev.adlin.vts4j.request.RequestDispatcher

public class RequestDispatcher extends Object
Dispatches outbound requests, manages tracking futures for expected asynchronous responses, and routes inbound network responses back to their matching execution tracks.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Purges all active pending trackers and forces their exceptional completion.
    boolean
    contains(@NonNull String requestId)
    Verifies if a specific request identifier is currently registered and awaiting a server reply.
    void
    dispatch(@NonNull Response response)
    Routes an incoming response from the network layer to its corresponding pending future track.
    send(@NonNull Request request)
    Dispatches an asynchronous request over the network layer and registers a tracking future to capture the incoming response.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RequestDispatcher

      public RequestDispatcher()
  • Method Details

    • send

      public @NonNull CompletableFuture<Response> send(@NonNull Request request)
      Dispatches an asynchronous request over the network layer and registers a tracking future to capture the incoming response.
      Parameters:
      request - the request packet containing a unique ID and payload data
      Returns:
      a CompletableFuture that resolves to the matching server Response
    • dispatch

      public void dispatch(@NonNull Response response)
      Routes an incoming response from the network layer to its corresponding pending future track.
      Parameters:
      response - the parsed server response package
    • contains

      public boolean contains(@NonNull String requestId)
      Verifies if a specific request identifier is currently registered and awaiting a server reply.
      Parameters:
      requestId - the unique request identifier to test
      Returns:
      true if monitored, false otherwise
    • closeAll

      public void closeAll()
      Purges all active pending trackers and forces their exceptional completion. Call this when the transport pipeline unexpectedly disconnects.