1

我已经使用带有 XLite 软件的星号 java 成功完成了出站呼叫。这次我想在没有 XLIte 的情况下拨打呼入电话。

public class HelloManager
{
    private ManagerConnection managerConnection;

    public HelloManager() throws IOException
    {
        ManagerConnectionFactory factory = new ManagerConnectionFactory(
                "192.168.68.173","manager", "password12345");

        this.managerConnection = factory.createManagerConnection();
    }

    public void run() throws IOException, AuthenticationFailedException,
            TimeoutException
    {
        OriginateAction originateAction;
        ManagerResponse originateResponse;

        originateAction = new OriginateAction();
        originateAction.setChannel("SIP/1010");
        originateAction.setContext("default");
        originateAction.setExten("2020");
        originateAction.setPriority(new Integer(1));
        originateAction.setTimeout(new Integer(30000));
        originateAction.setAsync(true);
         // connect to Asterisk and log in
     try {
      managerConnection.login();
     }
     catch(Exception e)
     {
         System.out.println(e.toString());
     }



        // send the originate action and wait for a maximum of 30 seconds for Asterisk
        // to send a reply
        originateResponse = managerConnection.sendAction(originateAction, 30000);

        // print out whether the originate succeeded or not
        System.out.println("Enter Response="+originateResponse.getResponse());

        // and finally log off and disconnect
        managerConnection.logoff();
    }

    public static void main(String[] args) throws Exception
    {
        HelloManager helloManager;

        helloManager = new HelloManager();
        helloManager.run();
    }
}

在上面的代码中,'originateResponse.getResponse()' 函数有助于发起出站呼叫。您知道我们如何实现由 AMI 发起的入站呼叫吗?是否需要 Asterisk AGI 来进行入站呼叫?

4

1 回答 1

0

如果您正在寻找没有 xlite 的入站呼叫。您需要在 java 中开发一个 sip 客户端并通过它进行所有通信。

否则,如果您正在寻找从星号获取信息(如回答时间、开始时间、状态)。那么您可以通过 AGI 实现相同的目标。在这种情况下,Xlite 是您的通信设备,但您可以与您的 java 程序共享星号调用相关记录

于 2014-02-13T02:44:50.460 回答