Re: [Asterisk-java-users] EVENT LISTENER PROBLEM
Brought to you by:
srt
From: Martin B. S. <ma...@mb...> - 2009-07-21 19:07:25
|
What class is action? Is it OriginateAction? For OriginateActions, Asterisk-Java has the ability to give you all of the events associated with the OriginateAction, through the OriginateResponseEvent. In your case, you're asking Asterisk-Java to send an action, wait 300000000 ms for a resultant event, and then do nothing with it. You're also looking at ((AbstractChannelEvent)event).getUniqueId(), which is the unique name of the channel. It won't contain your actionId. Since you do *not* want to wait for the result of the originate (you want to do more originates), you may want to use the callback version: void sendAction(ManagerAction action, SendActionCallback callback) "Sends a ManagerAction to the Asterisk server and registers a callback handler to be called when the corresponding ManagerResponse is received." And then ideally, the response should be an OriginateResponse: void onResponse(ManagerResponse response) Finally, have you considered using a proxy so you aren't sending actions and handling events in the same thread? http://asterisk-java.org/development/apidocs/org/asteriskjava/manager/ManagerEventListenerProxy.html Good luck, Martin Daniele Renda wrote: > Hi Martin, > the code is quite structurated but I try to paste the relevant points: > *CREATE THE ACTION (in a thread. This action then is send to the > Manager thread that send the action to Asterisk) > action.setContext(sContext); > action.setExten(sExten); > action.setPriority(new Integer(iPriority)); > action.setTimeout(new Long(iTimeout)); > action.setActionId(""+telefonata.getId()); > action.setAsync(true); > > *MANAGER (is a thread that send the action to Asterisk and waint ultil > the HangupEvent is throw or untile timeout) > ManagerConnectionFactory factory = new > ManagerConnectionFactory(asteriskHost, asteriskManagerPort, > asteriskManagerUser, asteriskManagerPsw); > this.managerConnection = factory.createManagerConnection(); > log.debug("Creata connessione al server Asterisk " + > managerConnection.getState()); > managerConnection.addEventListener(this.managerEventListener); > managerConnection.sendAction(getAsteriskAction(), 300000000); > try { > Thread.sleep(180000); > } catch (InterruptedException ex) { > } > } > log.debug("Sto effettuato la disconnessione dal Manager di Asterisk > sull'host " + managerConnection.getHostname()); > managerConnection.logoff(); > > *EVENT LISTENER (the listener to asterisk Event) > @Override > public void onManagerEvent(ManagerEvent event) { > log.debug("Evento "+((AbstractChannelEvent)event).getUniqueId()+" - " + event); > > The listener is very long and intercept all the events to asterisk. > > *DIALPLAN > The action that run from Java code is somethig as this: > Dial(trunk/telephoneNumber), extension s, priority 1, context > > [context] > exten => s,1,Answer() > ;I play a message > exten => s,2,Background(custom/message/intro) > exten => s,3,Hangup() > > In few words, this is an automatic call system that calls many users > and play them a simple vocal message. > My problem is that in the events that asterisk send to me (througt > Asterisk Java) there isn't something that tell to me which call the > refers. Infact all calls go to [context] and all make same things. > > Thanks > > Best regards > > > > 2009/7/21 Martin B. Smith <ma...@mb...>: >> Hi Daniel, >> >> That snippet doesn't help much; you don't even provide the declaration >> of the action variable or how you send it. Any number of things could be >> going on here, and we don't really have enough information to diagnose >> the problem. >> >> Furthermore, depending on how your dialplan is setup, your ability to >> determine which events correspond to which calls could be impaired. >> >> We'd really need a complete example of how you create and send the >> action, and how you handle the response; we'd also need to see any >> relevant dialplan contexts that the call may go into. >> >> Good luck, >> >> Martin >> >> >> >> Daniele Renda wrote: >>> Hi, >>> I'm using Asterisk Java with my Asterisk 1.6 and all works fine. I've only a >>> small problem with ManagerEventListener. I'm using the listener to >>> catch the event about a call that I've scheduled from Java. I create a >>> automatic call in this mode: >>> >>> >>> action.setContext(sContext); >>> action.setExten(sExten); >>> action.setPriority(new Integer(iPriority)); >>> action.setTimeout(new Long(iTimeout)); >>> action.setActionId(""+telefonata.getId()); >>> action.setAsync(true); >>> >>> All works fine if I make only ONE call at same time, but if I try to make >>> two or more calls I am not be able to detect wich events are of the >>> first call and which are of the second call. >>> The unique id of the events are not linked to the action that I've >>> submitted and the actionId that I can set is not included in the >>> response event. So how I can detect exactly the events of each call >>> separatly? >>> >>> >>> Thanks very much for your help! >>> Best regards >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> > > > |