Package dev.adlin.vts4j.request
Class RequestDispatcher
java.lang.Object
dev.adlin.vts4j.request.RequestDispatcher
Dispatches outbound requests, manages tracking futures for expected asynchronous responses,
and routes inbound network responses back to their matching execution tracks.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseAll()Purges all active pending trackers and forces their exceptional completion.booleanVerifies if a specific request identifier is currently registered and awaiting a server reply.voidRoutes an incoming response from the network layer to its corresponding pending future track.@NonNull CompletableFuture<Response> Dispatches an asynchronous request over the network layer and registers a tracking future to capture the incoming response.
-
Constructor Details
-
RequestDispatcher
public RequestDispatcher()
-
-
Method Details
-
send
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
CompletableFuturethat resolves to the matching serverResponse
-
dispatch
Routes an incoming response from the network layer to its corresponding pending future track.- Parameters:
response- the parsed server response package
-
contains
Verifies if a specific request identifier is currently registered and awaiting a server reply.- Parameters:
requestId- the unique request identifier to test- Returns:
trueif monitored,falseotherwise
-
closeAll
public void closeAll()Purges all active pending trackers and forces their exceptional completion. Call this when the transport pipeline unexpectedly disconnects.
-