我正在编写一个java应用程序来拨号并通过DTMF获得用户的pin。我使用asterisk-java
连接到星号VOIP服务器并拨打号码,但我不知道如何流式传输文件并读取用户的输入作为DTMF。下面是我的代码:
OriginateAction originateAction = new OriginateAction();
originateAction.setChannel("SIP/1001");
originateAction.setContext("default");
originateAction.setCallerId("Server");
originateAction.setPriority(1);
// connect to Asterisk and log in
managerConnection.login();
// send the originate action and wait for a maximum of 30 seconds for Asterisk
// to send a reply
ManagerResponse originateResponse = managerConnection.sendAction(originateAction, 30000);
// print out whether the originate succeeded or not
System.out.println(originateResponse.getResponse());
// and finally log off and disconnect
managerConnection.logoff();
您正在使用AMI。
如果没有拨号计划支持,AMI中无法获得dtmf。你可以通过ami获取事件,在dialplan
中使用如下命令exten => s,1,Read(variable,filetoplay)
exten => s,2,UserEvent(variable: variable)
或者您可以使用fastagi来控制调用执行并收集dtmf