Interface QueryPacketManager


public interface QueryPacketManager
Represents the manager used by the cloud to manage incoming and outgoing query packets.
Since:
4.0
  • Method Details

    • networkChannel

      @NonNull @NonNull NetworkChannel networkChannel()
      Get the network channel this manager is associated with. This channel is used to transmit query packets to the receiver, therefore the network channel of the received must be known in advance.
      Returns:
      the network channel to which this manager belongs.
    • waitingHandlerCount

      long waitingHandlerCount()
      Returns the approximate number of query response handlers that are currently awaiting a response. The returned value is an estimate, as the real value might differ due to concurrent sends of queries or receive of responses.
      Returns:
      the estimated number of handlers that are awaiting a response.
    • hasWaitingHandler

      boolean hasWaitingHandler(@NonNull @NonNull UUID queryUniqueId)
      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.
    • waitingHandler

      Gets and removes the waiting handler for the given query unique id.
      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

      Sends a query packet to the associated network channel, automatically selecting a query id for the packet and setting it. Equivalent to manager.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.