VoiceManager vm = AppContext.getManager(VoiceManager.class);
if (message instanceof GetPlayersInRangeRequestMessage) {
GetPlayersInRangeRequestMessage msg = (GetPlayersInRangeRequestMessage) message;
Player player = vm.getPlayer(msg.getPlayerID());
if (player == null) {
logger.warning("No player for " + msg.getPlayerID());
return;
}
Player[] playersInRange = player.getPlayersInRange();
String[] playerIDList = new String[playersInRange.length];
for (int i = 0; i < playersInRange.length; i++) {
playerIDList[i] = playersInRange[i].getId();
}
sender.send(clientID, new GetPlayersInRangeResponseMessage(msg.getPlayerID(),
playerIDList));
return;
}
if (message instanceof UDPPortTestMessage) {
UDPPortTestMessage msg = (UDPPortTestMessage) message;
try {
vm.testUDPPort(msg.getHost(), msg.getPort(), msg.getDuration());
} catch (IOException e) {
logger.warning("Unable to test udp port " + msg.getPort()
+ ": " + e.getMessage());
}
return;
}
if (message instanceof GetVoiceBridgeRequestMessage) {
logger.fine("Got GetVoiceBridgeMessage");
String callID = ((GetVoiceBridgeRequestMessage) message).getCallID();
if (callID != null) {
logger.info("Ending existing call " + callID);
Call call = vm.getCall(callID);
if (call != null) {
try {
call.end(false);
} catch (IOException e) {
logger.info("Unable to end call " + call
+ " " + e.getMessage());
}
} else {
logger.info("Can't find call for " + callID);
}
}
BridgeInfo bridgeInfo;
try {
bridgeInfo = vm.getVoiceBridge();
logger.info("Sending voice bridge info '" + bridgeInfo + "'");
} catch (IOException e) {
logger.warning("unable to get voice bridge: " + e.getMessage());
return;
}
sender.send(clientID, new GetVoiceBridgeResponseMessage(bridgeInfo.toString()));
return;
}
if (message instanceof PlaceCallRequestMessage) {
logger.fine("Got PlaceCallMessage from " + clientID);
placeCall(clientID, (PlaceCallRequestMessage) message);
return;
}
if (message instanceof EndCallMessage) {
EndCallMessage msg = (EndCallMessage) message;
String callID = msg.getCallID();
Call call = vm.getCall(callID);
if (call == null) {
logger.fine("Unable to end call " + callID);
return;
}
try {
vm.endCall(call, true);
} catch (IOException e) {
logger.warning(
"Unable to end call " + call + ": " + e.getMessage());
}
sender.send(new CallEndedMessage(msg.getCallID(), msg.getReason()));
return;
}
if (message instanceof MuteCallRequestMessage) {
MuteCallRequestMessage msg = (MuteCallRequestMessage) message;
String callID = msg.getCallID();
Call call = vm.getCall(callID);
if (call == null) {
logger.info("Unable to mute/unmute call " + callID);
return;
}
try {
call.mute(msg.isMuted());
} catch (IOException e) {
logger.warning("Unable to mute/unmute call " + callID + ": " + e.getMessage());
return;
}
return;
}
if (message instanceof TransferCallRequestMessage) {
TransferCallRequestMessage msg = (TransferCallRequestMessage) message;
String callID = msg.getPresenceInfo().getCallID();
Call call = vm.getCall(callID);
if (call == null) {
if (msg.getCancel() == true) {
return;
}
double x = 0;
double y = 0;
double z = 0;
double orientation = 0;
Player player = vm.getPlayer(callID);
if (player != null) {
x = -player.getX();
y = player.getY();
z = player.getZ();
orientation = player.getOrientation();
}
placeCall(clientID, new PlaceCallRequestMessage(msg.getPresenceInfo(),
msg.getPhoneNumber(), x, y, z, orientation, true));
return;