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.)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; }
processMessage(Message)
is public it is possible to call it from
another thread. To guard against this, many primitives add the following line to the
top of processMessage(Message)
that will add the message to the message
queue for processing in the proper thread:
if (!thisIsMe()) { MQ.put(msg); return NOOP; }
X-Midas Users Take Note: |
---|
![]() processMessage(Message) method.
|