com.limegroup.gnutella.messages
Class PingRequest

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

public class PingRequest
extends Message

A Gnutella ping message.

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
  PingRequest()
          Creates a QueryKey Request ping with a new GUID and TTL of 1
  PingRequest(byte ttl)
          Creates a normal ping with a new GUID
  PingRequest(byte[] guid, byte ttl, byte hops)
          Creates a normal ping from data read on the network
protected PingRequest(byte[] guid, byte ttl, byte hops, byte length)
          Creates an incoming group ping.
  PingRequest(byte[] guid, byte ttl, byte hops, byte[] payload)
          Creates a big ping request from data read from the network
protected PingRequest(byte ttl, byte length)
          Creates an outgoing group ping.
 
Method Summary
 boolean isQueryKeyRequest()
           
 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

PingRequest

public PingRequest(byte[] guid,
                   byte ttl,
                   byte hops)
Creates a normal ping from data read on the network


PingRequest

protected PingRequest(byte[] guid,
                      byte ttl,
                      byte hops,
                      byte length)
Creates an incoming group ping. Used only by boot-strap server


PingRequest

public PingRequest(byte[] guid,
                   byte ttl,
                   byte hops,
                   byte[] payload)
Creates a big ping request from data read from the network

Parameters:
payload - the headers etc. which the big pings contain.

PingRequest

public PingRequest(byte ttl)
Creates a normal ping with a new GUID

Parameters:
ttl - the ttl of the new Ping

PingRequest

protected PingRequest(byte ttl,
                      byte length)
Creates an outgoing group ping. Used only by boot-strap server

Parameters:
length - is length of the payload of the GroupPing = 14(port+ip+files+kbytes)+group.length + 1(null)

PingRequest

public PingRequest()
Creates a QueryKey Request ping with a new GUID and TTL of 1

Method Detail

writePayload

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

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

isQueryKeyRequest

public boolean isQueryKeyRequest()

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