com.aelitis.azureus.core.peermanager.utils
Class OutgoingBTHaveMessageAggregator

java.lang.Object
  extended by com.aelitis.azureus.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.


Constructor Summary
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.
 
Method Summary
 void destroy()
          Destroy the aggregator, along with any pending messages.
 void forceSendOfPending()
          Force send of any aggregated/pending have messages.
 boolean hasPending()
          Are there Haves messages pending?
 void queueHaveMessage(int piece_number, boolean force)
          Queue a new have message for aggregated sending.
 void setHaveVersion(byte bt_version, byte az_version)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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