[英]outgoing IVR through asterisk-java
I am building simple outgoing IVR with Asterisk and asterisk-java I installed Xlite soft phone in two different computers (A and B) in same network and setup them on asterisk and I can call them successfully Here is my asterisk-java code 我正在使用Asterisk和asterisk-java构建简单的传出IVR,我在同一网络中的两台不同的计算机(A和B)中安装了Xlite软电话,并在asterisk上设置了它们,我可以成功调用它们。这是我的asterisk-java代码
public class PhoneUtility {
private static ManagerConnection instanceManagerConnection;
private static ManagerConnection getManagerConnectionInstance() {
if (instanceManagerConnection == null) {
ManagerConnectionFactory factory = new
ManagerConnectionFactory("192.132.0.01", "admin", "amp111");
instanceManagerConnection = factory.createManagerConnection();
}
return instanceManagerConnection;
}
public static boolean phoneCall() {
try {
ManagerConnection managerConnection = getManagerConnectionInstance();
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setChannel("SIP/ivan");
originateAction.setCallerId("1234");
originateAction.setContext("ivr-ext");
originateAction.setExten("1235");
originateAction.setPriority(new Integer(1));
originateAction.setActionId("2");
originateAction.setTimeout(300000l);
originateAction.setAsync(new Boolean(false));
// connect to Asterisk and log in
managerConnection.login();
AsteriskServerImpl asteriskServer = new AsteriskServerImpl(managerConnection);
AsteriskChannel asteriskChannel = asteriskServer.originate(originateAction);
// Play a prompt by text to speach
Character dtmf = asteriskChannel.getDtmfSent();
if (dtmf.equals("1")) {
managerConnection.logoff();
return true;
} else {
managerConnection.logoff();
return false;
}
} catch (Exception e) {
System.out.println(e);
return false;
}
}
}
I execute the code (invoke phoneCall() ) in computer A to call computer B when the code is executed in computer A my soft phone rings in computer A first and I have to answer on soft phone computer A then computer B soft phone rings, How can I automatically open a channel for computer A through coding (I don't want to have soft phone in computer A at all) 我在计算机A中执行代码时在计算机A中执行代码(调用phoneCall())以呼叫计算机B。我的软电话先在计算机A中振铃,然后我必须在软电话计算机A上接听,然后在计算机B中软电话振铃,如何通过编码自动打开计算机A的频道(我根本不想在计算机A中安装软电话)
You Can make phone B rings first and if answered then the phone A rings (IVR-Extension which will be replaced by IVR APP which will auto-answer) by: 您可以先让电话B振铃,然后接听电话A振铃(IVR-Extension,它将被IVR APP取代,它将自动应答),方法是:
originateAction = new OriginateAction();
originateAction.setChannel("SIP/1235");
originateAction.setCallerId("1235");//put the target extension here
originateAction.setContext("ivr-ext");
originateAction.setExten("1234"); //put IVR-extension here
originateAction.setPriority(new Integer(1));
originateAction.setActionId("2");
originateAction.setTimeout(300000l);
originateAction.setAsync(new Boolean(false));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.