processMessage method.
processMessage(Message msg)
method.processMessage(Message msg) is automatically called when a message
arrives. (It is called in between calls to process(int))processMessage(Message msg) method, always make sure
to call super.processMessage(msg) to process any messages not recognized
(this is usually done last -- in the else clause).processMessage(Message msg) method, returns NORMAL if
a message has been processed and NOOP if it has not. (It is important
to note that some older primitives do not follow this rule.)processMessage(Message) is public it is possible to call it from
another thread. This is prevented by adding the if (!thisIsMe()) { MQ.put(msg); return NOOP; }
line to the top of the processMessage(Message msg)
if (!thisIsMe()) { MQ.put(msg); return NOOP; }
public int processMessage(Message msg) {
int status = NORMAL;
if (msg.getName().equals("FOO")) {
// do something
} else if (msg.getName().equals("BAR")) {
// do something
} else if (msg.getName().equals("BAZ")) {
// do something
} else {
status = super.processMessage(msg);
}
return status;
}
| X-Midas Users Take Note: |
|---|
X-Midas requires manual polling for messages from a global message section. In NeXtMidas
there is no "global" message system, all messages are directly sent to their intended
recipient. If the recipient is a primitive, it will automatically be passed into the
processMessage(Message) method.
|