String x = System.getProperty("x");
String y = System.getProperty("y");
String z = System.getProperty("z");
if (phoneNumber != null && phoneNumber.length() > 0) {
sendMessage(new PlaceCallRequestMessage(presenceInfo, phoneNumber,
Double.parseDouble(x), Double.parseDouble(y), Double.parseDouble(z), 90., false));
return;
}
SoftphoneControlImpl sc = SoftphoneControlImpl.getInstance();
/*
* The voice bridge info is a String of values separated by ":".
* The numbers indicate the index in tokens[].
*
* 0 1 2 3 4
* <bridgeId>::<privateHostName>:<privateControlPort>:<privateSipPort>
* 5 6 7
* :<publicHostName>:<publicControlPort>:<publicSipPort>
*/
String tokens[] = msg.getBridgeInfo().split(":");
String registrarAddress = tokens[5] + ";sip-stun:";
registrarAddress += tokens[7];
localAddress = null;
try {
InetAddress ia = NetworkAddress.getPrivateLocalAddress(
"server:" + tokens[5] + ":" + tokens[7] + ":10000");
localAddress = ia.getHostAddress();
} catch (UnknownHostException e) {
logger.warning(e.getMessage());
logger.warning("The client is unable to connect to the bridge " +
"public address. Trying InetAddress.getLocalHost().");
try {
//InetAddress ia = NetworkAddress.getPrivateLocalAddress(
// "server:" + tokens[2] + ":" + tokens[4] + ":10000");
//localAddress = ia.getHostAddress();
localAddress = InetAddress.getLocalHost().getHostAddress();
if (localAddress.startsWith("127")) {
logger.warning("local address is " + localAddress
+ ". This can only work if the server is running locally.");
}
} catch (UnknownHostException ee) {
logger.warning(ee.getMessage());
}
}
if (localAddress != null) {
try {
String sipURL = sc.startSoftphone(presenceInfo.getUserID().getUsername(),
registrarAddress, 10, localAddress);
logger.fine("Starting softphone: " + presenceInfo);
if (sipURL != null) {
// XXX need location and direction
sendMessage(new PlaceCallRequestMessage(
presenceInfo, sipURL, Double.parseDouble(x), Double.parseDouble(y), Double.parseDouble(z), 90., false));
} else {
logger.warning("Failed to start softphone, retrying.");
try {