if (message instanceof VoiceChatJoinMessage == false) {
logger.warning("Invalid message type " + message);
return;
}
VoiceChatJoinMessage msg = (VoiceChatJoinMessage) message;
if (audioGroup == null) {
AudioGroupSetup setup = new AudioGroupSetup();
setup.spatializer = new FullVolumeSpatializer();
setup.spatializer.setAttenuator(Spatializer.DEFAULT_MAXIMUM_VOLUME);
setup.virtualPlayerListener = this;
setup.audioGroupListener = this;
audioGroup = vm.createAudioGroup(group, setup);
}
PresenceInfo[] calleeList = msg.getCalleeList();
PresenceInfo caller = msg.getCaller();
if (msg.getChatType() != null) {
Player player = vm.getPlayer(caller.getCallID());
if (player == null) {
logger.warning("No Player for " + caller.getCallID());
return;
}
boolean added = addPlayerToAudioGroup(audioGroup, player, caller, msg.getChatType());
if (added) {
sender.send(new VoiceChatJoinAcceptedMessage(group, caller, msg.getChatType()));
}
if (added == false && (calleeList == null || calleeList.length == 0)) {
endVoiceChat(vm, audioGroup);
return;
}
}
logger.info("Request to join AudioGroup " + group + " caller " + caller);
if (calleeList == null || calleeList.length == 0) {
return;
}
for (int i = 0; i < calleeList.length; i++) {
PresenceInfo info = calleeList[i];
String callID = info.getCallID();
Player player = vm.getPlayer(callID);
if (player == null) {
logger.warning("No player for callID " + callID);
continue;
}
if (info.getClientID() == null) {
/*
* This is an outworlder. We automatically join them to the group
* The InCallDialog can be used to change the privacy setting
* and to remove the outworlder from the chat.
*/
addPlayerToAudioGroup(audioGroup, player, info, msg.getChatType());
sender.send(new VoiceChatJoinAcceptedMessage(group, info, msg.getChatType()));
continue;
}
AudioGroupPlayerInfo playerInfo = audioGroup.getPlayerInfo(player);
if (playerInfo != null && sameChatType(playerInfo.chatType, msg.getChatType())) {
logger.fine("Player " + info
+ " is already in audio group " + audioGroup);
if (playerInfo.isTransientMember == false) {
continue;
}
}
WonderlandClientID id =
CommsManagerFactory.getCommsManager().getWonderlandClientID(info.getClientID());
if (id == null) {
logger.warning("No WonderlandClientID for " + info);
continue;
}
Call call = player.getCall();
if (call != null) {
try {
call.playTreatment("audioGroupInvite.au");
} catch (IOException e) {
logger.warning("Unable to play audioGroupInvite.au: "
+ e.getMessage());
}
}
logger.warning("Asking " + info + " to join audio group "
+ group + " chatType " + msg.getChatType());
requestPlayerJoinAudioGroup(sender, id, group, caller,
calleeList, msg.getChatType());
}
}