com.limegroup.gnutella
Class StandardMessageRouter

java.lang.Object
  extended bycom.limegroup.gnutella.MessageRouter
      extended bycom.limegroup.gnutella.StandardMessageRouter

public class StandardMessageRouter
extends MessageRouter

This class is the message routing implementation for TCP messages.


Field Summary
 
Fields inherited from class com.limegroup.gnutella.MessageRouter
_clientGUID, _manager, UNICASTER
 
Constructor Summary
StandardMessageRouter()
           
 
Method Summary
protected  java.util.List createQueryReply(byte[] guid, byte ttl, long speed, Response[] res, byte[] clientGUID, boolean busy, boolean uploaded, boolean measuredSpeed, boolean isFromMcast)
          Creates a List of QueryReply instances with compressed XML data, if requested.
protected  void handlePingReply(PingReply pingReply, ReplyHandler receivingConnection)
          The default handler for PingRequests received in ManagedConnection.loopForMessages().
protected  void respondToPingRequest(PingRequest ping, ReplyHandler handler)
          Responds to a Gnutella ping with cached pongs.
protected  boolean respondToQueryRequest(QueryRequest queryRequest, byte[] clientGUID)
          Respond to the query request.
protected  void respondToUDPPingRequest(PingRequest request, java.net.DatagramPacket datagram, ReplyHandler handler)
          Responds to a ping request received over a UDP port.
 boolean sendResponses(Response[] responses, QueryRequest query)
           
 
Methods inherited from class com.limegroup.gnutella.MessageRouter
broadcastPingRequest, bufferResponsesForLaterDelivery, forwardQueryRequestToLeaves, getPingRouteTableDump, getPushRouteTableDump, getQueryRouteTable, getQueryRouteTableDump, handleLimeACKMessage, handleMessage, handleMulticastMessage, handlePushProxyRequest, handlePushRequest, handleQueryReply, handleQueryRequest, handleQueryStatus, handleTCPConnectBackRequest, handleUDPConnectBackRequest, handleUDPMessage, handleUDPPingReply, handleUDPPingRequest, hasValidQueryKey, initialize, multicastQueryRequest, originateQuery, removeConnection, responsesToQueryReplies, sendAcknowledgement, sendDynamicQuery, sendMulticastPushRequest, sendPingReply, sendPingRequest, sendPushRequest, sendQueryKeyPong, sendQueryReply, sendQueryRequest, sendQueryRequest, unicastQueryRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardMessageRouter

public StandardMessageRouter()
Method Detail

respondToPingRequest

protected void respondToPingRequest(PingRequest ping,
                                    ReplyHandler handler)
Responds to a Gnutella ping with cached pongs. This does special handling for both "heartbeat" pings that were sent to ensure that the connection is still live as well as for pings from a crawler.

Specified by:
respondToPingRequest in class MessageRouter
Parameters:
ping - the PingRequest to respond to
handler - the ReplyHandler to send any pongs to

respondToUDPPingRequest

protected void respondToUDPPingRequest(PingRequest request,
                                       java.net.DatagramPacket datagram,
                                       ReplyHandler handler)
Responds to a ping request received over a UDP port. This is handled differently from all other ping requests. Instead of responding with a pong from this node, we respond with a pong from other UltraPeers supporting UDP from our cache.

Specified by:
respondToUDPPingRequest in class MessageRouter
Parameters:
request - the PingRequest to service
datagram - the DatagramPacket containing the IP and port of the client node
handler - the ReplyHandler that should handle any replies

handlePingReply

protected void handlePingReply(PingReply pingReply,
                               ReplyHandler receivingConnection)
Description copied from class: MessageRouter
The default handler for PingRequests received in ManagedConnection.loopForMessages(). This implementation uses the ping route table to route a ping reply. If an appropriate route doesn't exist, records the error statistics. On sucessful routing, the PingReply count is incremented.

In all cases, the ping reply is recorded into the host catcher.

Override as desired, but you probably want to call super.handlePingReply if you do.

Overrides:
handlePingReply in class MessageRouter

respondToQueryRequest

protected boolean respondToQueryRequest(QueryRequest queryRequest,
                                        byte[] clientGUID)
Description copied from class: MessageRouter
Respond to the query request. Implementations typically will either do nothing (if they don't think a response is appropriate) or call sendQueryReply(QueryReply). This method is called from the default handleQueryRequest.

Specified by:
respondToQueryRequest in class MessageRouter

sendResponses

public boolean sendResponses(Response[] responses,
                             QueryRequest query)

createQueryReply

protected java.util.List createQueryReply(byte[] guid,
                                          byte ttl,
                                          long speed,
                                          Response[] res,
                                          byte[] clientGUID,
                                          boolean busy,
                                          boolean uploaded,
                                          boolean measuredSpeed,
                                          boolean isFromMcast)
Creates a List of QueryReply instances with compressed XML data, if requested.

Specified by:
createQueryReply in class MessageRouter
Returns:
a new List of QueryReply instances