[英]How can I originate a call and read DTMF value using asterisk-java?
I'm developing a java application that should be able to call another party using Java-Asterisk and get a DTMF value from user. 我正在开发一个Java应用程序,该应用程序应该能够使用Java-Asterisk调用另一方并从用户那里获取DTMF值。 I am using originate
command of AMI and I'm stuck. 我使用的originate
AMI的命令,我被卡住。 I can call the other party but the call is ended immediately after answering and returns success
. 我可以打电话给对方,但接听电话后会立即结束并返回success
。
How can I originate a call and read a DTMF value? 如何发起呼叫并读取DTMF值?
OriginateAction originateAction = new OriginateAction();
originateAction.setChannel("SIP/1001");
originateAction.setContext("from-internal");
originateAction.setExten("1002");
originateAction.setCallerId("Server");
originateAction.setPriority(1);
originateAction.setTimeout(30000);
// 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 response= managerConnection.sendAction(originateAction, 30000);
The Originate action in the AMI allows you to send a request over a TCP connection for Asterisk to make a call. AMI中的Originate操作可让您通过TCP连接发送请求,以使Asterisk进行呼叫。 This is the most popular method for originating calls from custom applications. 这是从自定义应用程序发起呼叫的最流行方法。 The example provided in the solution starts by having Asterisk make a new call to SIP/1001
. 解决方案中提供的示例从让Asterisk再次调用SIP/1001
。 If the phone does not answer within 30 seconds, the call will be aborted. 如果电话在30秒钟内未接听电话,则通话将中止。 If the call is answered, it is connected to extension 1002 in the from-internal
context in the dialplan. 如果呼叫已应答,则在拨号计划中的from-internal
上下文中将其连接到分机1002。 After calling 1002 extension all i need to read DTMF is this: 呼叫1002分机后,我需要阅读DTMF的内容是:
public class HelloAgiScript extends BaseAgiScript {
public void service(AgiRequest request, AgiChannel channel) throws AgiException
{
// Answer the channel...
answer();
// ...say hello and get DTMF data...
String data = getData("welcome");
// ...and hangup.
hangup();
}
} }
click here to see the original HelloAgiScript. 单击此处查看原始的HelloAgiScript。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.