Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value after OriginateAction
Brought to you by:
srt
From: Yves A. <yv...@gm...> - 2013-03-06 11:38:25
|
hi, pls. see attached source... package tests; import org.asteriskjava.live.AsteriskChannel; import org.asteriskjava.live.DefaultAsteriskServer; import org.asteriskjava.live.LiveException; import org.asteriskjava.live.OriginateCallback; import org.asteriskjava.manager.ManagerConnection; import org.asteriskjava.manager.action.OriginateAction; public class CallTestWithCallbackHandler { private static ManagerConnection managerConnection; public static void main(String[] args) throws Exception{ DefaultAsteriskServer asteriskServer = new DefaultAsteriskServer("SERVER", "USER", "PASSWORD"); asteriskServer.getManagerConnection().login(); try { OriginateAction originateAction = new OriginateAction(); originateAction.setChannel("SIP/177");//first leg originateAction.setContext("from-internal"); originateAction.setExten("08154711"); //second leg originateAction.setPriority(1); originateAction.setTimeout(15000); asteriskServer.originateAsync(originateAction, new myCallbackHandler("177")); System.out.println("now idling for a minute to get a chance to receive events and states..."); try { Thread.sleep(60000); } catch (Exception e) { System.out.println(e.getMessage()); } } catch (Exception e) { System.out.println(e.getMessage()); } } } package tests; import org.asteriskjava.live.AsteriskChannel; import org.asteriskjava.live.LiveException; import org.asteriskjava.live.OriginateCallback; public class myCallbackHandler implements OriginateCallback{ public String reference; public myCallbackHandler(String reference){ System.out.println("myCallbackHandler for reference "+reference+" just instantiated."); this.reference = reference; } public void onDialing(AsteriskChannel ac) { System.out.println("myCallbackHandler for reference "+reference+" receives state: Dialling, channelID is: "+ac.getId()+", State is: "+ac.getState()); String channelID=ac.getId(); } public void onBusy(AsteriskChannel ac) { System.out.println("myCallbackHandler for reference "+reference+" receives state: Busy, channelID is: "+ac.getId()+", State is: "+ac.getState()); } public void onFailure(LiveException le) { System.out.println("myCallbackHandler for reference "+reference+" receives state: Failure "+le.getMessage()); } public void onNoAnswer(AsteriskChannel ac) { System.out.println("myCallbackHandler for reference "+reference+" receives state: No Answer, channelID is: "+ac.getId()+", State is: "+ac.getState()); } public void onSuccess(AsteriskChannel ac) { System.out.println("myCallbackHandler for reference "+reference+" receives state: Success, channelID is: "+ac.getId()+", State is: "+ac.getState()); } } regards, yves Am 06.03.2013 04:57, schrieb roko: > Hi > > I use the SendActionCallback, but I'm getting the same response that I > get from the blocking function... no new data. So, how can I get the > value of the ORIGINATE_STATUS variable ? > > E. > > ------------------------------------------------------------------------ > *De:* roko <ro...@ya...> > *Para:* "ast...@li..." > <ast...@li...> > *Enviado:* Lunes, 4 de marzo, 2013 10:38 A.M. > *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value > after OriginateAction > > Hi > > Thx for your answer. Do you mean instead of blocking using: > > ManagerResponse > <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html> sendAction(ManagerAction > <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action, > long timeout) > > Should I use this function ?: > > void sendAction(ManagerAction > <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action, > SendActionCallback > <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/SendActionCallback.html> callback) > > I see in the docs that I still get a ManagerResponse > <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>. > Pls forgive me, I'm very new at this. How can I get the > ORIGINATE_STATUS from the ManagerResponse object ? Do you have an > example that I could use ? Thx for your help. > > E. > > ------------------------------------------------------------------------ > *De:* Yves A. <yv...@gm...> > *Para:* ast...@li... > *Enviado:* Lunes, 4 de marzo, 2013 2:45 A.M. > *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value > after OriginateAction > > Hi, > > you could use a callback handler. this way you´ll get informed about > any state change. > > yves > > Am 04.03.2013 04:06, schrieb roko: >> Hi everyone >> >> I'm just starting with asterisk and asterisk-java, so please forgive >> me if this is a silly question. Here >> (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate) >> <http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate> I can see >> that the originate cmd sets the ORIGINATE_STATUS variable before >> exiting. How can I get this value from asterisk-java ? At this point >> I'm using the code from the tutorial, like this: >> OriginateAction originateAction; >> ManagerResponse originateResponse; >> >> originateAction = new OriginateAction(); >> originateAction.setChannel("SIP/John"); >> originateAction.setContext("default"); >> originateAction.setExten("1300"); >> originateAction.setPriority(new Integer(1)); >> originateAction.setTimeout(new Integer(30000)); >> >> managerConnection.login(); >> originateResponse = managerConnection.sendAction(originateAction, 30000); >> Thx for your help. >> >> E. >> >> >> ------------------------------------------------------------------------------ >> Everyone hates slow websites. So do we. >> Make your web apps faster with AppDynamics >> Download AppDynamics Lite for free today: >> http://p.sf.net/sfu/appdyn_d2d_feb >> >> >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... <mailto:Ast...@li...> >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > ------------------------------------------------------------------------------ > Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester > Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the > endpoint security space. For insight on selecting the right partner to > tackle endpoint security challenges, access the full report. > http://p.sf.net/sfu/symantec-dev2dev > > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |