VoiceManager vm = AppContext.getManager(VoiceManager.class);
String group = message.getGroup();
PresenceInfo callee = message.getCallee();
String externalCallID = group + "-" + callNumber++;
callee = new PresenceInfo(callee.getCellID(), callee.getClientID(),
callee.getUserID(), externalCallID);
String softphoneCallID = message.getSoftphoneCallID();
Call softphoneCall = vm.getCall(softphoneCallID);
Player softphonePlayer = null;
if (softphoneCall != null) {
softphonePlayer = softphoneCall.getPlayer();
}
if (softphonePlayer == null) {
logger.warning("Softphone player is not connected!");
sender.send(clientID, new VoiceChatCallEndedMessage(
group, callee, "Softphone is not connected!"));
return;
}
logger.fine("EXTERNAL CALLID IS " + externalCallID + " "
+ " softphone callID " + softphoneCallID + " softphone call "
+ softphoneCall + " softphone player " + softphonePlayer);
logger.fine("Got place call message " + externalCallID);
PlayerSetup playerSetup = new PlayerSetup();
playerSetup.x = softphonePlayer.getX();
playerSetup.y = 1.5;
playerSetup.z = softphonePlayer.getZ();
playerSetup.isOutworlder = true;
playerSetup.isLivePlayer = true;
CallSetup setup = new CallSetup();
setup.externalOutgoingCall = true;
CallParticipant cp = new CallParticipant();
setup.cp = cp;
try {
setup.bridgeInfo = vm.getVoiceBridge();
} catch (IOException e) {
logger.warning("Unable to get voice bridge for call " + cp + ": "
+ e.getMessage());
sender.send(clientID, new VoiceChatCallEndedMessage(
group, callee, "No voice bridge available!"));
return;
}
AudioGroup audioGroup = vm.getAudioGroup(group);
if (audioGroup == null) {
logger.warning("No audio group " + group);
sender.send(clientID, new VoiceChatCallEndedMessage(
group, callee, "Audio group not found!"));
return;
}
cp.setPhoneNumber(message.getPhoneNumber());
cp.setName(callee.getUsernameAlias());
cp.setCallId(externalCallID);
cp.setConferenceId(vm.getVoiceManagerParameters().conferenceId);
cp.setVoiceDetection(true);
cp.setDtmfDetection(true);
cp.setVoiceDetectionWhileMuted(true);
cp.setHandleSessionProgress(true);
new VoiceChatPhoneStatusListener(group, callee, externalCallID, clientID);
Call externalCall;
try {
externalCall = vm.createCall(externalCallID, setup);
} catch (IOException e) {
logger.warning("Unable to create call " + cp + ": "
+ e.getMessage());
sender.send(clientID, new VoiceChatCallEndedMessage(
group, callee, "Can't create call!"));
return;
}
Player externalPlayer = vm.createPlayer(externalCallID, playerSetup);
externalCall.setPlayer(externalPlayer);
externalPlayer.setCall(externalCall);
callee = new PresenceInfo(null, null, callee.getUserID(), externalCallID);
VoiceChatHandler.getInstance().addPlayerToAudioGroup(audioGroup,
externalPlayer, callee, message.getChatType());
//if (message.getChatType() == ChatType.PUBLIC) {