sg.edu.nus.peer.request
Class ServerPnPSender

java.lang.Object
  extended by java.util.TimerTask
      extended by sg.edu.nus.peer.request.UDPSender
          extended by sg.edu.nus.peer.request.ServerPnPSender
All Implemented Interfaces:
java.lang.Runnable, java.util.EventListener, PnPListener, UDPListener

public class ServerPnPSender
extends UDPSender
implements PnPListener

The ServerPnPSender is responsible for sending UDP packets with the type of MsgType.PING out to bootstrapper, server peers in its routing table and all its client peers.

The method sendPacket() must be implemented to send UDP packages to remote peers. To obtain the IP address list of the remote peers to be contacted, the sender needs to use ServerPeer.BOOTSTRAP_SERVER and ServerPeer.BOOTSTRAP_SERVER_PORT to find bootstrapper, and TreeNode structure of ServerPeer.getListItem(int) to find both server peers in its routing table and all its client peers.

Version:
1.0 2006-10-9
Author:
Xu Linhao
See Also:
ServerPnPServer, UDPSender

Constructor Summary
ServerPnPSender(AbstractMainFrame gui, int port)
          Construct the UDP sender with specified parameters.
 
Method Summary
 void nodeAlive(PeerInfo info)
          This method will be invoked if a node is still alive.
 void nodeFailure(PeerInfo info)
          This method will be invoked when a node is detected as failure.
 
Methods inherited from class sg.edu.nus.peer.request.UDPSender
getDatagramSocket, getLocalPort, isAlive, run
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerPnPSender

public ServerPnPSender(AbstractMainFrame gui,
                       int port)
                throws java.net.SocketException
Construct the UDP sender with specified parameters.

Parameters:
gui - the reference of the AbstractMainFrame
port - the port to be used for initializing DatagramSocket
Throws:
java.net.SocketException - if cannot initialize DatagramSocket on the specified port
Method Detail

nodeAlive

public void nodeAlive(PeerInfo info)
Description copied from interface: PnPListener
This method will be invoked if a node is still alive.

Specified by:
nodeAlive in interface PnPListener
Parameters:
info - the PeerInfo instance

nodeFailure

public void nodeFailure(PeerInfo info)
Description copied from interface: PnPListener
This method will be invoked when a node is detected as failure.

Specified by:
nodeFailure in interface PnPListener
Parameters:
info - the PeerInfo instance