}
public void messageReceived(WonderlandClientSender sender,
WonderlandClientID clientID, Message message) {
TextChatMessage tcm = (TextChatMessage)message;
// First, notify listeners of a new message. On the server side,
// all listeners get all messages, even if they're sent to
// specific people. It's up to listeners to decide what to do
// with them.
for(ManagedReference listenerRef : this.listeners) {
TextChatMessageListener listener = (TextChatMessageListener)listenerRef.get();
logger.info("Sending to listener: " + listener);
listener.handleMessage(tcm);
}
// Check to see if the message is a meant for everyone by looking at
// the "to" field. If so, then echo the message back to all clients
// except the one that sent the message.
String toUser = tcm.getToUserName();
Set<WonderlandClientID> clientIDs = sender.getClients();
if (toUser == null || toUser.equals("") == true) {
clientIDs.remove(clientID);
sender.send(clientIDs, message);