com.limegroup.gnutella.messages
Class PushRequest

java.lang.Object
  extended bycom.limegroup.gnutella.messages.Message
      extended bycom.limegroup.gnutella.messages.PushRequest
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class PushRequest
extends Message
implements java.io.Serializable

A Gnutella push request, used to download files behind a firewall.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.limegroup.gnutella.messages.Message
F_PING, F_PING_REPLY, F_PUSH, F_QUERY, F_QUERY_REPLY, F_ROUTE_TABLE_UPDATE, F_VENDOR_MESSAGE, F_VENDOR_MESSAGE_STABLE, N_MULTICAST, N_TCP, N_UDP, N_UNKNOWN, RECORD_STATS, SOFT_MAX
 
Constructor Summary
PushRequest(byte[] guid, byte ttl, byte[] clientGUID, long index, byte[] ip, int port)
          Creates a new PushRequest from scratch.
PushRequest(byte[] guid, byte ttl, byte hops, byte[] payload, int network)
          Wraps a PushRequest around stuff snatched from the network.
 
Method Summary
 byte[] getClientGUID()
           
 long getIndex()
           
 byte[] getIP()
           
 int getPort()
           
 void recordDrop()
          Records the dropping of this message in statistics.
 Message stripExtendedPayload()
          Returns a message identical to this but without any extended (typically GGEP) data.
 java.lang.String toString()
           
protected  void writePayload(java.io.OutputStream out)
           
 
Methods inherited from class com.limegroup.gnutella.messages.Message
compareTo, getCreationTime, getFunc, getGUID, getHops, getLength, getNetwork, getPriority, getTotalLength, getTTL, hop, isMulticast, isTCP, isUDP, isUnknownNetwork, makeGuid, read, read, read, read, read, readNullTerminatedBytes, repOk, setGUID, setHops, setPriority, setTTL, updateLength, write, writeGemExtension, writeGemExtension, writeGemExtensions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PushRequest

public PushRequest(byte[] guid,
                   byte ttl,
                   byte hops,
                   byte[] payload,
                   int network)
            throws BadPacketException
Wraps a PushRequest around stuff snatched from the network.

Throws:
BadPacketException - the payload length is wrong

PushRequest

public PushRequest(byte[] guid,
                   byte ttl,
                   byte[] clientGUID,
                   long index,
                   byte[] ip,
                   int port)
Creates a new PushRequest from scratch.

Method Detail

writePayload

protected void writePayload(java.io.OutputStream out)
                     throws java.io.IOException
Specified by:
writePayload in class Message
Throws:
java.io.IOException

getClientGUID

public byte[] getClientGUID()

getIndex

public long getIndex()

getIP

public byte[] getIP()

getPort

public int getPort()

stripExtendedPayload

public Message stripExtendedPayload()
Description copied from class: Message
Returns a message identical to this but without any extended (typically GGEP) data. Since Message's are mostly immutable, the returned message may alias parts of this; in fact the returned message could even be this. The caveat is that the hops and TTL field of Message can be mutated for efficiency reasons. Hence you must not call hop() on either this or the returned value. Typically this is not a problem, as hop() is called before forwarding/broadcasting a message.

Specified by:
stripExtendedPayload in class Message
Returns:
an instance of this without any dangerous extended payload

recordDrop

public void recordDrop()
Description copied from class: Message
Records the dropping of this message in statistics.

Specified by:
recordDrop in class Message

toString

public java.lang.String toString()
Overrides:
toString in class Message