Class OutgoingBTHaveMessageAggregator

java.lang.Object
com.biglybt.core.peermanager.utils.OutgoingBTHaveMessageAggregator

public class OutgoingBTHaveMessageAggregator extends Object
Utility class to enable write aggregation of BT Have messages, in order to save bandwidth by not wasting a whole network packet on a single small 9-byte message, and instead pad them onto other messages.
  • Field Details

    • pending_haves

      private final ArrayList pending_haves
    • pending_haves_mon

      private final AEMonitor pending_haves_mon
    • bt_have_version

      private byte bt_have_version
    • az_have_version

      private byte az_have_version
    • destroyed

      private boolean destroyed
    • outgoing_message_q

      private final OutgoingMessageQueue outgoing_message_q
    • added_message_listener

      private final OutgoingMessageQueue.MessageQueueListener added_message_listener
  • Constructor Details

    • OutgoingBTHaveMessageAggregator

      public OutgoingBTHaveMessageAggregator(OutgoingMessageQueue outgoing_message_q, byte _bt_have_version, byte _az_have_version)
      Create a new aggregator, which will send messages out the given queue.
      Parameters:
      outgoing_message_q -
  • Method Details

    • setHaveVersion

      public void setHaveVersion(byte bt_version, byte az_version)
    • queueHaveMessage

      public void queueHaveMessage(int piece_number, boolean force)
      Queue a new have message for aggregated sending.
      Parameters:
      piece_number - of the have message
      force - if true, send this and any other pending haves right away
    • destroy

      public void destroy()
      Destroy the aggregator, along with any pending messages.
    • forceSendOfPending

      public void forceSendOfPending()
      Force send of any aggregated/pending have messages.
    • hasPending

      public boolean hasPending()
      Are there Haves messages pending?
      Returns:
      true if there are any unsent haves, false otherwise
    • sendPendingHaves

      private void sendPendingHaves()