@Override
public void handleMessage(Message message) {
logger.fine("got a message... " + message);
if (message instanceof ClientConnectResponseMessage) {
ClientConnectResponseMessage msg = (ClientConnectResponseMessage) message;
CellCache cellCache = ClientContext.getCellCache(session);
if (cellCache == null) {
logger.warning("Can't find cellCache for session " + session);
return;
}
ArrayList<String> nameTagList = new ArrayList();
PresenceInfo[] presenceInfoList = msg.getPresenceInfoList();
for (int i = 0; i < presenceInfoList.length; i++) {
PresenceInfo presenceInfo = presenceInfoList[i];
logger.fine("Client connected: " + presenceInfo);
logger.fine("Got ClientConnectResponse: adding pi " + presenceInfo);
pm.presenceInfoAdded(presenceInfo);
String username = presenceInfo.getUserID().getUsername();
if (presenceInfo.getCellID() == null) {
logger.warning("CellID is null for " + presenceInfo);
continue;
}
Cell cell = cellCache.getCell(presenceInfo.getCellID());
if (cell == null) {
logger.warning("Unable to find cell for " + presenceInfo.getCellID());
continue;
}
NameTagComponent nameTag = cell.getComponent(NameTagComponent.class);
if (presenceInfo.getUsernameAlias().equals(username) == false) {
pm.changeUsernameAlias(presenceInfo, presenceInfo.getUsernameAlias());
}
if (nameTag == null) {
continue;
}
nameTag.updateLabel(presenceInfo.getUsernameAlias(),
presenceInfo.isInConeOfSilence(),
presenceInfo.isSpeaking(),
presenceInfo.isMuted());
}
// if (nameTagList.size() > 0) {
// new NameTagUpdater(nameTagList);
// }
// connection is complete
setConnectionComplete(true);
return;
}
// Issue #1113: if the connection is not complete, ignore messages
if (!isConnectionComplete()) {
return;
}
if (message instanceof PlayerInRangeMessage) {
PlayerInRangeMessage msg = (PlayerInRangeMessage) message;
PresenceInfo info = pm.getPresenceInfo(msg.getCallID());
if (info == null) {
logger.fine("no presence info for callID " + msg.getCallID());
return;
}
pm.playerInRange(info, msg.isInRange());
return;
}
if (message instanceof PresenceInfoAddedMessage) {
PresenceInfoAddedMessage m = (PresenceInfoAddedMessage) message;