Interface QueryPacketManager
- All Known Implementing Classes:
DefaultQueryPacketManager
public interface QueryPacketManager
Represents the manager used by the cloud to manage incoming and outgoing query packets.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanhasWaitingHandler(@NonNull UUID queryUniqueId) Checks if a waiting handler is registered (and therefore still waiting for a result) for the given unique id.Get the network channel this manager is associated with.Get the duration before a query is marked as unanswered and the associated future gets completed with an empty packet.sendQueryPacket(@NonNull Packet packet) Sends a query packet to the associated network channel, automatically selecting a query id for the packet and setting it.sendQueryPacket(@NonNull Packet packet, @NonNull UUID queryUniqueId) Sends a query packet to the associated network channel, automatically setting the id in the packet.booleanunregisterWaitingHandler(@NonNull UUID queryUniqueId) Unregisters the waiting handler by the given unique id.waitingHandler(@NonNull UUID queryUniqueId) Gets, but does not remove the waiting handler for the given unique id.@NonNull @UnmodifiableView Map<UUID,eu.cloudnetservice.common.concurrent.Task<Packet>> Get all registered queries which are currently waiting for a response.
-
Method Details
-
queryTimeout
Get the duration before a query is marked as unanswered and the associated future gets completed with an empty packet.- Returns:
- the timeout of a query.
-
networkChannel
Get the network channel this manager is associated with. Each network channel has its own query manager.- Returns:
- the network channel to which this manager belongs.
- See Also:
-
waitingHandlers
@NonNull @NonNull @UnmodifiableView Map<UUID,eu.cloudnetservice.common.concurrent.Task<Packet>> waitingHandlers()Get all registered queries which are currently waiting for a response.- Returns:
- all waiting queries.
-
hasWaitingHandler
Checks if a waiting handler is registered (and therefore still waiting for a result) for the given unique id.- Parameters:
queryUniqueId- the unique id of the query to check for.- Returns:
- true if the handler is still registered, false otherwise.
- Throws:
NullPointerException- if the given unique id is null.
-
unregisterWaitingHandler
Unregisters the waiting handler by the given unique id.- Parameters:
queryUniqueId- the unique id of the handler to unregister.- Returns:
- true if the handler was unregistered, false otherwise.
- Throws:
NullPointerException- if the given handler unique id is null.
-
waitingHandler
@Nullable @Nullable eu.cloudnetservice.common.concurrent.Task<Packet> waitingHandler(@NonNull @NonNull UUID queryUniqueId) Gets, but does not remove the waiting handler for the given unique id. Null if no handler with the given unique id is still registered.- Parameters:
queryUniqueId- the unique id of the handler to get.- Returns:
- the waiting handler associated with the given unique id, null if no handler with that id is waiting.
- Throws:
NullPointerException- if the given unique id is null.
-
sendQueryPacket
@NonNull @NonNull eu.cloudnetservice.common.concurrent.Task<Packet> sendQueryPacket(@NonNull @NonNull Packet packet) Sends a query packet to the associated network channel, automatically selecting a query id for the packet and setting it. Equivalent tomanager.sendQueryPacket(packet, UUID.randomUUID(). An existing query unique id in the packet will get overridden.- Parameters:
packet- the packet to convert to a query packet and send to the channel.- Returns:
- a future completed with either the response to the packet or an empty packet if the waiting time expires.
- Throws:
NullPointerException- if the given packet is null.
-
sendQueryPacket
@NonNull @NonNull eu.cloudnetservice.common.concurrent.Task<Packet> sendQueryPacket(@NonNull @NonNull Packet packet, @NonNull @NonNull UUID queryUniqueId) Sends a query packet to the associated network channel, automatically setting the id in the packet. An existing query unique id in the packet will get overridden.- Parameters:
packet- the packet to convert to a query packet and send to the channel.queryUniqueId- the unique id to use when sending the packet.- Returns:
- a future completed with either the response to the packet or an empty packet if the waiting time expires.
- Throws:
NullPointerException- if either the given packet or unique id is null.
-