sg.edu.nus.peer.request
Class ServerPnPReceiver

java.lang.Object
  extended by sg.edu.nus.peer.request.UDPReceiver
      extended by sg.edu.nus.peer.request.ServerPnPReceiver
All Implemented Interfaces:
java.lang.Runnable

public class ServerPnPReceiver
extends UDPReceiver

The ServerPnPReceiver is responsible for listening any incoming UDP packets from remote peers. The received UDP packets have the message type of MsgType.PONG or MsgType.TROUBLESHOOT.

To process each received UDP packet, a set of handlers are pre-initialized in the method setupHandlers(). If the system-defined timeout runs out, then the receiver sets timeout signal as true to notify the sender to start a new round of UDP packets dissemination.

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

Constructor Summary
ServerPnPReceiver(AbstractMainFrame gui, java.net.DatagramSocket ds, int maxConn)
          Construct the receiver with specified parameters.
 
Method Summary
 void setupHandlers()
          Initiate a set of UDPHandlers and the maximum number of handlers is specified by the parameter maxConn.
 void stop()
          Stop all UDPHandlers and do necessary clearup job.
 
Methods inherited from class sg.edu.nus.peer.request.UDPReceiver
addUDPListener, getDatagramSocket, getLocalPort, isAlive, removeUDPListener, run
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerPnPReceiver

public ServerPnPReceiver(AbstractMainFrame gui,
                         java.net.DatagramSocket ds,
                         int maxConn)
                  throws java.net.SocketException
Construct the receiver with specified parameters.

Parameters:
gui - the reference of the AbstractMainFrame
ds - the reference of the DatagramSocket
maxConn - the maximum number of handlers to be used for processing UDP packets
Throws:
java.net.SocketException
Method Detail

setupHandlers

public void setupHandlers()
Description copied from class: UDPReceiver
Initiate a set of UDPHandlers and the maximum number of handlers is specified by the parameter maxConn.

Specified by:
setupHandlers in class UDPReceiver

stop

public void stop()
Description copied from class: UDPReceiver
Stop all UDPHandlers and do necessary clearup job.

Specified by:
stop in class UDPReceiver