Re: [Asterisk-java-users] originate a call and get user selected option
Brought to you by:
srt
From: Kelly G. <kel...@gm...> - 2013-01-02 16:53:10
|
Hi, I implemented the MenuEvent class as you suggested, and I can see this line on the console Executing [1@ivr:1] UserEvent("SIP/eu-34001bd0", "Menu,uid:1357145308.1,selection:1") in new stack But in the java code, the event is not received. My class is as follows: public class AsteriskLive implements ManagerEventListener { private ManagerConnection managerConnection; public AsteriskLive() { } @Override public void onManagerEvent(ManagerEvent event) { if(event instanceof MenuEvent){ System.out.println(event); } } public void run() throws IOException, AuthenticationFailedException, TimeoutException, InterruptedException { ManagerConnectionFactory factory = new ManagerConnectionFactory("1.1.1.2", "a", "p"); ManagerConnection managerConnection = factory.createManagerConnection(); managerConnection.registerUserEventClass(MenuEvent.class); OriginateAction originateAction; originateAction = new OriginateAction(); originateAction.setChannel("SIP/eu"); originateAction.setContext("ivr"); originateAction.setExten("400"); originateAction.setPriority(new Integer(1)); managerConnection.addEventListener(this); managerConnection.login(); managerConnection.sendAction(originateAction, 30000); Thread.sleep(60); managerConnection.logoff(); } public static void main(String[] args) throws Exception { AsteriskLive helloLiveEvents = new AsteriskLive(); helloLiveEvents.run(); } } And the MenuEvent class public class MenuEvent extends UserEvent { public MenuEvent(Object source) { super(source); } private static final long serialVersionUID = 1L; } And the extensions.conf exten => 1,2,MP3Player(confirmed.mp3) exten => 1,1,UserEvent(Menu,uid:${UNIQUEID},selection:${EXTEN}) On Wed, Jan 2, 2013 at 2:27 PM, Mordechay Kaganer <mka...@gm...>wrote: > B.H. > > > > On Wed, Jan 2, 2013 at 5:49 PM, Kelly Goedert <kel...@gm...>wrote: > >> Hi, > > > Hello > > >> >> I need to originate a call from java, this call is made to an extension >> which plays menu options to the user, like, press 1 to confirm and 2 to >> cancel. >> >> I originate a call to the extension 400@ivr that looks like this: >> >> [ivr] >> exten => 400,1,MP3Player(sound1.mp3) >> exten => 400,2,Background(menu.mp3) >> exten => 400,n,WaitExten(5) >> >> exten => 1,1,MP3Player(confirmed.mp3) >> >> exten => 2,1,MP3Player(cancel.mp3) >> exten => 3,1,MP3Player(later.mp3) >> exten => 4,1,Goto(ivr,400,2) >> exten => i,1,MP3Player(invalid.mp3) >> exten => t,1,Hangup() >> >> Is it possible to know if the user selected 1,2,3 or 4? If so, how can I >> do that? >> >> Thanks >> >> Kelly >> >> > AFAIK, Asterisk 1.4 sends NewExtenEvent on every priority in the dialplan > but the later versions do not send this event. I would recommend to use > cusom UserEvent like this on every extention of the menu: > > exten => s,n,UserEvent(MENU,uid: ${UNIQUEID},selection: ${EXTEN}) > > (you need to pass the channel's UNIQUEID because for some reason it is not > passed automatically by asterisk for user events) > > Then you create a class MenuEvent (The class name matters!) which > extends org.asteriskjava.manager.event.UserEvent and register it with your > AMI connection: > > connection.registerUserEventClass(MenuEvent.class); > > Another solution whould be to use FastAGI, if it is applicable in your > case > > >> >> >> ------------------------------------------------------------------------------ >> Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery >> and much more. Keep your Java skills current with LearnJavaNow - >> 200+ hours of step-by-step video tutorials by Java experts. >> SALE $49.99 this month only -- learn more at: >> http://p.sf.net/sfu/learnmore_122612 >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> >> > Best regards, Mordechay > > -- > משיח NOW! > Moshiach is coming very soon, prepare yourself! > יחי אדוננו מורינו ורבינו מלך המשיח לעולם ועד! > > > ------------------------------------------------------------------------------ > Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery > and much more. Keep your Java skills current with LearnJavaNow - > 200+ hours of step-by-step video tutorials by Java experts. > SALE $49.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122612 > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > |