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;
logger.fine("GOT PresenceInfoAddedMessage for " + m.getPresenceInfo());
pm.presenceInfoAdded(m.getPresenceInfo());
return;
}
if (message instanceof PresenceInfoRemovedMessage) {
PresenceInfoRemovedMessage m = (PresenceInfoRemovedMessage) message;
PresenceInfo pi = pm.getPresenceInfo(m.getCellID());
if (pi == null) {
logger.warning("No presence info found for " + m.getCellID());
return;
}
logger.fine("GOT PresenceInfoRemovedMessage for " + pi);
pm.presenceInfoRemoved(pi);
return;
}
if (message instanceof PresenceInfoChangedMessage) {
PresenceInfoChangedMessage m = (PresenceInfoChangedMessage) message;
PresenceInfo pi = pm.getPresenceInfo(m.getCellID());
if (pi == null) {
logger.warning("No presence info found for " + m.getCellID());
return;
}
logger.fine("GOT PresenceInfoChangeMessage for " + pi);
switch (m.getChange()) {
case SPEAKING:
pm.setSpeaking(pi, m.getValue());
break;
case MUTED:
pm.setMute(pi, m.getValue());
break;
case SECRET_CHAT:
pm.setInSecretChat(pi, m.getValue());
break;
case CONE_OF_SILENCE:
pm.setEnteredConeOfSilence(pi, m.getValue());
break;
}
return;
}
if (message instanceof PresenceInfoChangedAliasMessage) {
PresenceInfoChangedAliasMessage m = (PresenceInfoChangedAliasMessage) message;
PresenceInfo pi = pm.getPresenceInfo(m.getCellID());
if (pi == null) {
logger.warning("No presence info found for " + m.getCellID());
return;
}