|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jade.core.behaviours.Behaviour | +--jade.core.behaviours.SimpleBehaviour | +--jade.proto.states.MsgReceiver
This behaviour is a simple implementation of a message receiver. It puts into the given key of the given datastore the received message according to the given message template and timeout. All these data must be passed in the constructor. If the timeout expires before any message arrives, the behaviour terminates and put null into the datastore.
Field Summary | |
protected long |
deadline
|
static int |
INFINITE
A numeric constant to mean that the deadline for the receive operation will never expire. |
static int |
INTERRUPTED
A numeric constant to mean that the receive operation was interrupted. |
protected java.lang.Object |
receivedMsgKey
|
protected MessageTemplate |
template
|
static int |
TIMEOUT_EXPIRED
A numeric constant to mean that a timeout expired. |
Fields inherited from class jade.core.behaviours.Behaviour |
myAgent |
Constructor Summary | |
MsgReceiver(Agent a,
MessageTemplate mt,
long deadline,
DataStore s,
java.lang.Object msgKey)
Constructor. |
Method Summary | |
protected void |
handleMessage(ACLMessage msg)
This is invoked when a message matching the specified template is received or the timeout has expired (the msg
parameter is null in this case). |
void |
interrupt()
Signal an interruption to this receiver, and cause the ongoing receive operation to abort. |
void |
reset(MessageTemplate mt,
long deadline,
DataStore s,
java.lang.Object msgKey)
Reset this behaviour, possibly replacing the receive templatt and other data. |
void |
setDeadline(long deadline)
This method allows modifying the deadline |
void |
setReceivedKey(java.lang.Object key)
This method allows modifying the key in the DS where to put the received message |
void |
setTemplate(MessageTemplate mt)
This method allows modifying the template |
Methods inherited from class jade.core.behaviours.SimpleBehaviour |
reset |
Methods inherited from class jade.core.behaviours.Behaviour |
action, block, block, done, getBehaviourName, getDataStore, getParent, isRunnable, onEnd, onStart, restart, root, setAgent, setBehaviourName, setDataStore |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TIMEOUT_EXPIRED
public static final int INTERRUPTED
public static final int INFINITE
protected MessageTemplate template
protected long deadline
protected java.lang.Object receivedMsgKey
Constructor Detail |
public MsgReceiver(Agent a, MessageTemplate mt, long deadline, DataStore s, java.lang.Object msgKey)
a
- a reference to the Agentmt
- the MessageTemplate of the message to be received, if null
the first received message is returned by this behaviourdeadline
- a timeout for waiting until a message arrives. It must
be expressed as an absolute time, as it would be returned by
System.currentTimeMillisec()
s
- the dataStore for this bheaviourmsgKey
- the key where the beahviour must put the received
message into the DataStore.Method Detail |
protected void handleMessage(ACLMessage msg)
msg
parameter is null in this case). Users may redefine this method
to react to this event. The default implementation of does nothing.
public void reset(MessageTemplate mt, long deadline, DataStore s, java.lang.Object msgKey)
mt
- The template to match ACL messages against during the
receive operation.deadline
- The relative timeout of the receive
operation. If the INFINITE
constant is used, then
no deadline is set and the operation will wait until a matching
ACL message arrives.s
- The datastore where the received ACL message is to be
put.msgKey
- The key to use to put the received message into
the selected datastore.public void setDeadline(long deadline)
public void setTemplate(MessageTemplate mt)
public void setReceivedKey(java.lang.Object key)
public void interrupt()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |