Interface Responder

All Superinterfaces:
java.rmi.Remote

public interface Responder
extends java.rmi.Remote

The Responder replies to requests about its local routing network.


Method Summary
 void activate()
          Activate the Responder - used by the Finder.
 void addGoldenPath(java.util.Vector goldenPath)
          Once the Finder retrieves a golden path it can report it to the Responder.
 AntResponsePair getNeighborsOfCurrentNode(int antID, Location location)
          Provides a vector of Locations to which the Ant can move, or kills the ant.
 void increaseRoundNumber()
          Increases the round number (The first round is 1).
 void resolveGoldenPaths()
          Asks the Responder to check if all the paths that have been previously supplied to it are valid.
 int updateAntLocation(int antID, Location newLocation)
          Updates the Locations of the Ant in the network.
 

Method Detail

activate

void activate()
              throws java.rmi.RemoteException
Activate the Responder - used by the Finder. This allows the Responder to initialize itself, and should be the first method which is invoked by the Finder.

Throws:
java.rmi.RemoteException - There is no RMI communication

increaseRoundNumber

void increaseRoundNumber()
                         throws java.rmi.RemoteException
Increases the round number (The first round is 1). Finder should first use it when increasing the round number from 1 to 2. It should be invoked after the Ants had finished requesting information about the network, and updated their locations.

Throws:
java.rmi.RemoteException - There is no RMI communication

getNeighborsOfCurrentNode

AntResponsePair getNeighborsOfCurrentNode(int antID,
                                          Location location)
                                          throws java.rmi.RemoteException
Provides a vector of Locations to which the Ant can move, or kills the ant.

Parameters:
location - The current location of ant.
antID - The ant's ID (a number between 1 to 30).
Returns:
AntResponsePair. when listOfLocations is empty that means that the Ant was not allowed to ask this question. Otherwise, there should be at least one Location and not more than four. If killAnt is set to true that means that the Responder killed the Ant.
Throws:
java.rmi.RemoteException - There is no RMI connection

updateAntLocation

int updateAntLocation(int antID,
                      Location newLocation)
                      throws java.rmi.RemoteException
Updates the Locations of the Ant in the network.

Parameters:
antID - The ant's ID (a number between 1 to 30).
newLocation - The new location of the Ant.
Returns:
int: 1 - The location of the Ant has been updated. 0 - The location of the Ant hasn't been updated. -1 - The Ant was killed by the Responder.
Throws:
java.rmi.RemoteException - There is no RMI connection

addGoldenPath

void addGoldenPath(java.util.Vector goldenPath)
                   throws java.rmi.RemoteException
Once the Finder retrieves a golden path it can report it to the Responder. Note, that the Responder doesn't give a feedback if the path is correct. Actually the Responder doesn't even have to check it yet.

Parameters:
goldenPath - A Vector of Locations in the golden path.
Throws:
java.rmi.RemoteException

resolveGoldenPaths

void resolveGoldenPaths()
                        throws java.rmi.RemoteException
Asks the Responder to check if all the paths that have been previously supplied to it are valid. The Responder displays the paths on the screen or states "Finder finds nothing".

Throws:
java.rmi.RemoteException - There is no RMI connection