madkit.demos
Class PingPong

java.lang.Object
  extended by madkit.kernel.AbstractAgent
      extended by madkit.kernel.Agent
          extended by madkit.demos.PingPong
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class PingPong
extends Agent

See Also:
Serialized Form

Constructor Summary
PingPong()
           
 
Method Summary
 void activate()
          This method sets the agent to create or join a "ping-pong" group, and then registers it with a role of "player" Could be simpler, but I wanted to show a complete and careful implementation
 void end()
          This method is called by the agent micro-kernel at the end of the agent lifecycle.
 AgentAddress getOther()
          This method allows the user to get the "other" agent address in the G-Box property sheet
 void live()
          This method defines the main behavior for threaded agents.
 void setOther(AgentAddress add)
          This method allows the user to set the "other" agent with the G-Box property sheet
 
Methods inherited from class madkit.kernel.Agent
connectAgencyToAgency, createPlace, createPlace, enableMobility, enableMobility, exitImmediatlyOnKill, getAgencyNamed, joinPlace, joinPlace, joinPlace, pause, receiveMessage, run, waitNextMessage, waitNextMessage
 
Methods inherited from class madkit.kernel.AbstractAgent
broadcastMessage, broadcastMessage, connectedWithCommunity, createGroup, createGroup, debug, disposeMyGUI, foundGroup, getAddress, getAgentInformation, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getAgentWithRole, getAvailableCommunities, getBean, getController, getCurrentKernelAddress, getDebug, getExistingGroups, getExistingGroups, getExistingRoles, getExistingRoles, getGroups, getGUIObject, getMessageBoxSize, getMyGroups, getMyGroups, getMyRoles, getMyRoles, getName, getRoles, hasGUI, initGUI, isBelongingToGroup, isBelongingToGroup, isCommunity, isGroup, isGroup, isMemberOf, isMemberOf, isMessageBoxEmpty, isRole, isRole, joinGroup, killAgent, launchAgent, launchAgent, leaveGroup, leaveGroup, leaveRole, leaveRole, nextMessage, print, println, redisplayMyGUI, requestRole, requestRole, requestRole, restoreAgent, sendMessage, sendMessage, sendMessage, setBean, setController, setDebug, setGUIObject, setName, setOutput, setOutputWriter, windowClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PingPong

public PingPong()
Method Detail

setOther

public void setOther(AgentAddress add)
This method allows the user to set the "other" agent with the G-Box property sheet


getOther

public AgentAddress getOther()
This method allows the user to get the "other" agent address in the G-Box property sheet


activate

public void activate()
This method sets the agent to create or join a "ping-pong" group, and then registers it with a role of "player" Could be simpler, but I wanted to show a complete and careful implementation

Overrides:
activate in class AbstractAgent

live

public void live()
Description copied from class: Agent
This method defines the main behavior for threaded agents.

Overrides:
live in class Agent

end

public void end()
Description copied from class: AbstractAgent
This method is called by the agent micro-kernel at the end of the agent lifecycle. If the the agent is killed from the outside, it is the last opportunity for the agent to cleanly shutdown its operations.

Overrides:
end in class AbstractAgent


Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.