2014-02-12 84 views
1

我已經使用帶有XLite軟件的星號java成功完成了呼出呼叫。這次我想在沒有XLIte的情況下撥打電話。如何使用星號java進行呼入呼叫

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()」功能可以intiate您對我們如何才能實現已發起的AMI呼入呼叫任何想法出境calls.Do?是否有任何需要的Asterisk的AGI打入電話?

回答

0

如果您正在尋找與xlite無關的入站呼叫,您需要在java中開發一個SIP客戶端,並通過它進行所有通信。

否則,如果您正在尋找從星號獲取信息(如回答時間,開始時間,狀態)。然後您可以通過AGI實現相同。在這種情況下,Xlite是您的通信設備,但您可以與您的java程序共享星號呼叫相關記錄

+0

星號AMI和AGI腳本本身可行來創建SIP客戶端(軟電話)? –