我正在编写一个Java应用程序以拨打号码并通过DTMF获取用户的密码。我正在使用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。

没有Dialplan支持,无法在AMI中获取dtmf。您可以使用Dialplan中的类似内容通过ami获取事件

exten => s,1,Read(variable,filetoplay)
exten => s,2,UserEvent(variable: variable)


或者您可以使用fastagi来控制呼叫执行并收集dtmf

关于java - 使用 Asterisk Java读取dtmf,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23472983/

10-13 03:10