org.catnets.p2pagent.apiSamples.gropcastEchoes
Class EchoServer

java.lang.Object
  extended by org.catnets.p2pagent.api.P2pAgent
      extended by org.catnets.p2pagent.apiSamples.gropcastEchoes.EchoServer
All Implemented Interfaces:
org.catnets.p2pagent.hosting.AccessPoint, org.catnets.p2pagent.hosting.Task

public class EchoServer
extends org.catnets.p2pagent.api.P2pAgent

Receives a message and replies to the originator with the same message, after waiting for a random time, wich simulates the server's response time.

Author:
Pablo Chacin

Constructor Summary
EchoServer()
           
 
Method Summary
protected  void execute()
          Executes the sever main logic, that limits to read parameters.
protected  void handleEvent(org.catnets.p2pagent.api.Event event)
          Handles the expiration of the event used to delay the response
protected  void handleGroupCast(java.lang.String group, org.catnets.p2pagent.api.AgentMessage message)
          Handles a meesage from a client and prepares the response.
 
Methods inherited from class org.catnets.p2pagent.api.P2pAgent
createAgent, done, done, error, forward, getAgentName, getAgentRefence, getBooleanArgument, getDoubleArgument, getIntArgument, getLongArgument, getObjectArgument, getStringArgument, getTransactionId, groupCast, groupCast, handleConnection, handleMessage, initialize, isArgumentsEmpty, joinGroup, log, logDebug, logError, logInfo, logWarning, reply, reportMetric, reportMetric, reportMetric, run, scheduleEvent, send, setBooleanResult, setDoubleResult, setIntgResult, setLongResult, setObjectResult, setStringResult, startTransaction, terminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EchoServer

public EchoServer()
Method Detail

execute

protected void execute()
Executes the sever main logic, that limits to read parameters. The server then goes to wait for messages from clients.

Specified by:
execute in class org.catnets.p2pagent.api.P2pAgent

handleGroupCast

protected void handleGroupCast(java.lang.String group,
                               org.catnets.p2pagent.api.AgentMessage message)
Handles a meesage from a client and prepares the response. After receiving the message, the server generates a random delay time and schedules an event for that time to send a response. The event receives as parameter the original message, which is needed to replay to sender.

Overrides:
handleGroupCast in class org.catnets.p2pagent.api.P2pAgent

handleEvent

protected void handleEvent(org.catnets.p2pagent.api.Event event)
Handles the expiration of the event used to delay the response

Overrides:
handleEvent in class org.catnets.p2pagent.api.P2pAgent
Parameters:
event - Event with the infomation of the event, including the original message that must be replied.