|
Agent System POND 1.2 (28.2.2002) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--PkgAgentSystem.Conversation
A conversation with a single or any number of other agents. Each time a message is received, the
method handleMessage
is called, which should handle the incoming message (and
probably send a message in return or end the conversation). When a conversation is started, this
method is called once with the parameter null
.
Subclasses must be declared as public
classes and must
declare public final static long conversationTypeID=...
. Only the value may
and must change (unique values required, at least for all conversations a single agents
knows and uses). Otherwise the type of the conversation cannot be retrieved by
this class.
Incoming messages starting a new conversation are handled by cloning the prototype. It is
therefore necessary to override clone()
if structured members are contained in
the conversation.
AgentBase
, Serialized FormField Summary | |
static long |
conversationTypeID
The ID for this type of conversation. |
protected boolean |
uniquePartner
If true , this conversation has only a single partner. |
Constructor Summary | |
protected |
Conversation(AgentBase myAgent)
Creates a new conversation of a certain agent. |
protected |
Conversation(AgentBase myAgent,
AgentIdentity counterpart)
Creates a new conversation of a certain agent with another agent. |
Method Summary | |
protected void |
broadcastMessage(BroadcastMessage msg)
Sends a broadcast to all other local agents. |
protected void |
endConversation()
Stops this conversation. |
protected void |
fillInConversationData(MessageType msg)
Fills in the necessary data if it is missing and otherwise verifies it. |
protected AgentBase |
getAgent()
Returns the agent this conversation belongs to. |
long |
getConversationTypeID()
|
protected long |
getCounterpartConvID()
Returns the conversation ID of this conversation for the counterpart agent. |
protected AgentIdentity |
getCounterpartIdentity()
Returns the identity of the counterpart agent. |
long |
getOwnConvID()
Returns the conversation ID of this conversation for this agent. |
protected boolean |
handleMessage(MessageType msg)
Handle the message. |
protected boolean |
isInitiator()
Returns true if this agent initiated the conversation. |
boolean |
isRunning()
Check whether this conversation is currently active. |
Conversation |
newConversation(AgentIdentity counterpart)
Creates a new conversation based on this one through cloning. |
Conversation |
newConversation(AgentIdentity counterpart,
boolean asInitiator)
Creates a new conversation based on this one through cloning. |
protected void |
sendMessage(Message msg)
Sends a message to another agent. |
protected void |
setCounterpartConvID(long counterpartConvID)
Sets the conversation ID of this conversation for the counterpart agent. |
protected void |
setCounterpartIdentity(AgentIdentity other)
Sets the identity of the counterpart agent. |
protected void |
setInitiator(boolean asInitiator)
Sets this instance as the initiator of the conversation. |
protected void |
setOwnConvID(long newID)
Modifies our own serial ID for this conversation. |
protected void |
setShouldArchive(boolean shouldArchive)
Sets the archivation status for this conversation. |
protected boolean |
shouldArchive()
Returns whether this conversation should be archived after termination or not. |
protected boolean |
startConversation()
Starts this conversation. |
void |
waitEnded()
Blocks until this conversation has ended ( endConversation() was called).
|
Methods inherited from class java.lang.Object |
|
Field Detail |
protected boolean uniquePartner
true
, this conversation has only a single partner.public static final long conversationTypeID
A identical field MUST be declared in EACH subclass!
Only the value may and must change (unique values required, at least for all conversations a single agents knows and uses).Constructor Detail |
protected Conversation(AgentBase myAgent)
serialID
- the ID of this conversationmyAgent
- the agent this conversation belongs toprotected Conversation(AgentBase myAgent, AgentIdentity counterpart)
serialID
- the ID of this conversationmyAgent
- the agent this conversation belongs tocouterpart
- the other agent with which this conversation takes placeMethod Detail |
protected void setInitiator(boolean asInitiator)
protected AgentBase getAgent()
protected boolean handleMessage(MessageType msg)
msg
- the message to handletrue
if this message was handled.public long getOwnConvID()
protected void setOwnConvID(long newID)
newID
- the new ID for this conversationgetOwnConvID()
protected long getCounterpartConvID()
protected void setCounterpartConvID(long counterpartConvID)
counterpartConvID
- the conversation ID of the other agentgetCounterpartConvID()
protected void setCounterpartIdentity(AgentIdentity other)
other
- the identity of the remote agentgetCounterpartIdentity()
protected AgentIdentity getCounterpartIdentity()
public Conversation newConversation(AgentIdentity counterpart)
counterpart
- the counterpart of the conversation (might be null)public Conversation newConversation(AgentIdentity counterpart, boolean asInitiator)
counterpart
- the counterpart of the conversation (might be null)asInitiator
- whether we are the initiator or notprotected boolean startConversation()
handleMessage(null)
)protected void endConversation()
protected boolean shouldArchive()
true
if the conversation should be archivedprotected void setShouldArchive(boolean shouldArchive)
shouldArchive
- if true
this conversation will be archived after terminationprotected void sendMessage(Message msg) throws MessageException
msg
- the message to sendprotected void broadcastMessage(BroadcastMessage msg) throws MessageException
msg
- the message to sendpublic boolean isRunning()
true
if this conversation has been started but has not yet endedpublic void waitEnded()
endConversation()
was called).
Can NOT be interrupted!protected boolean isInitiator()
true
if this agent initiated the conversationpublic final long getConversationTypeID()
protected void fillInConversationData(MessageType msg)
|
Agent System POND 1.2 (28.2.2002) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |