Methods Summary |
---|
public void | notifyIncomingMessage(MessageConnection mc)/
/**
Notify the message processor to exit
synchronized(mutex) {
mutex.notify();
}
|
public void | run()Thread's run method to wait for and process received messages.
Message msg = null;
while (!done) {
// Try reading (maybe block for) a message
try {
synchronized(mutex) {
mutex.wait();
}
msg = mc.receive();
} catch (Exception e) {
// Handle reading errors
System.out.println("Exception while receiving message " + e);
continue;
}
/********************************/
/* Process the received message */
/********************************/
if (msg instanceof TextMessage) {
TextMessage tmsg = (TextMessage)msg;
// Notify listener about new text message...
incomingMessageListener.onTextMessage(tmsg.getAddress(), tmsg.getPayloadText());
} else {
if (msg instanceof BinaryMessage) {
BinaryMessage bmsg = (BinaryMessage)msg;
// Notify listener about new binary message...
incomingMessageListener.onBinaryMessage(bmsg.getAddress(), bmsg.getPayloadData());
} else {
// Ignore
}
}
} // while
|
protected void | setIncomingMessageListener(IncomingMessageListener listener)Sets the WMAFramework incoming message nofitication listener.
incomingMessageListener = listener;
|
protected void | start()Notify the message processor to exit
try {
mc.setMessageListener(this);
} catch (Exception e) {
}
th.start();
|
protected void | stop()Notify the message processor to exit
done = true;
|