Re: [Asterisk-java-users] Reading a variable after call ends
Brought to you by:
srt
From: Yves A. <yv...@gm...> - 2013-08-07 09:10:58
|
good to know... thanks for sharing, yves Am 07.08.2013 09:31, schrieb Daniele Renda: > Hi Yves, > at the end I reused the PropertyChangeListener. So I check the event > in this manner: > > if (evt != null && > evt.getPropertyName().equalsIgnoreCase("currentExtension")) { > if (evt.getNewValue() instanceof Extension) { > if (e.getApplication().equalsIgnoreCase("Set")) { > if (e.getAppData() != null && > !e.getAppData().isEmpty()) { > > So I can know when in the dialplan is set a Variable. Not sure if this > is the best way but in this manner I don't use a new listener. > > Thanks for your support. > > > 2013/8/5 Daniele Renda <dan...@gm... > <mailto:dan...@gm...>> > > Sure, every time I remove the listener before adding new one. > > In effect my system should manage many calls, about 1500/2500 at day. > > On the other hand, using an Agiscript I have the problem that in > my method I should update the db but doing so I update the db > either in agiscript and then in the code of originateAsync and may > be not simple manage locking of record because can happen that > modification can be concurrent. > > Thanks > > > > > 2013/8/5 Yves A. <yv...@gm... <mailto:yv...@gm...>> > > hi, > > this looks ok for me... as long as you dont forget to remove > the listener. > I also would check the impact to the whole system / > performance / memory usage depending on the amount of calls > your code has to handle... i could imagine that this is not > healthy for high traffic... if you have a high call volume you > maybe should go another way.... but try it out and give feedback, > > yves > > > Am 05.08.2013 16:33, schrieb Daniele Renda: >> Ah ok, >> the problem is that I need to know the value of the variable >> inside "private class MyOriginateCallback implements >> OriginateCallback" because I need the reference of my "Call" >> object that is inside this class. >> So every time I should add and remove listener from >> managerconnection is this way: >> >> channel.getServer().getManagerConnection().addEventListener(new >> ManagerEventListener() { >> >> @Override >> public void onManagerEvent(ManagerEvent event) { >> if (event instanceof VarSetEvent) { >> VarSetEvent varEvent = (VarSetEvent) >> event; >> String variabile = >> varEvent.getVariable(); >> log.debug("Impostata variabile: " + variabile + " su >> telefonata " + telefonata.getId()); >> String valore = varEvent.getValue(); >> log.debug("Valore : " + valore + " su telefonata " + >> telefonata.getId()); >> } >> >> } >> }); >> >> What do you think? >> >> Thanks >> >> >> >> >> 2013/8/5 Yves A. <yv...@gm... <mailto:yv...@gm...>> >> >> no... >> >> i don´t think that the propertychangeeventlistener will >> receive varsetevents.... >> you´ll have to open a managerconnection and add an >> eventlistener to it.. >> >> y. >> >> >> Am 05.08.2013 16:03, schrieb Daniele Renda: >>> Hi Yves, >>> thanks for your suggestion. >>> >>> You mean that in ; >>> >>> channel.addPropertyChangeListener(new >>> PropertyChangeListener() { >>> >>> @Override >>> public void >>> propertyChange(PropertyChangeEvent evt) { >>> >>> I need to test: >>> >>> if (evt.getSource() instanceof VarSetEvent) >>> >>> Right? >>> >>> Thanks >>> >>> >>> >>> 2013/8/5 Yves A. <yv...@gm... <mailto:yv...@gm...>> >>> >>> Have you tried to "listen" to the VarSetEvent ? >>> >>> yves >>> >>> Am 05.08.2013 14:29, schrieb Daniele Renda: >>>> Hi yves, >>>> sorry for the lack of details. >>>> >>>> I do this: >>>> >>>> OriginateAction action = createAction(telefonata); >>>> try { >>>> telefonata.onCreate(); >>>> asteriskServer.originateAsync(action, new >>>> MyOriginateCallback(telefonata)); >>>> } catch (ManagerCommunicationException e) { >>>> log.error(telefonata.getId() + " ha generato un >>>> errore", e); >>>> telefonata.onFailure(); >>>> } >>>> >>>> private class MyOriginateCallback implements >>>> OriginateCallback { >>>> >>>> private final TelefonataInterface telefonata; >>>> >>>> private MyOriginateCallback(TelefonataInterface >>>> telefonata) { >>>> this.telefonata = telefonata; >>>> } >>>> >>>> @Override >>>> public void onDialing(final AsteriskChannel >>>> channel) { >>>> log.debug("On dialing comunicazione " + >>>> telefonata.getId()); >>>> telefonata.onDialing(); >>>> channel.addPropertyChangeListener(new >>>> PropertyChangeListener() { >>>> >>>> @Override >>>> public void propertyChange(PropertyChangeEvent >>>> evt) { >>>> if (evt.getSource() instanceof AsteriskChannel) { >>>> >>>> // EVENTO DI HANGUP >>>> if (channel.getState() == >>>> ChannelState.HUNGUP) { >>>> String hangupCauseText = ""; >>>> if (channel.getHangupCauseText() != null) >>>> hangupCauseText = channel.getHangupCauseText(); >>>> telefonata.onHangupEvent(channel); >>>> } >>>> >>>> } >>>> }); >>>> } >>>> >>>> @Override >>>> public void onSuccess(AsteriskChannel >>>> channel) { >>>> log.debug("Success " + telefonata.getId() + " " + >>>> channel); >>>> log.debug("La comunicazione è iniziata alle " + >>>> channel.getDateOfCreation()); >>>> telefonata.onSuccess(); >>>> } >>>> >>>> @Override >>>> public void onNoAnswer(AsteriskChannel >>>> channel) { >>>> log.debug("NoAnswer " + telefonata.getId() + " " + >>>> channel); >>>> telefonata.onNoAnswer(); >>>> } >>>> >>>> @Override >>>> public void onBusy(AsteriskChannel channel) { >>>> log.debug("Busy " + telefonata.getId() + " " + >>>> channel); >>>> telefonata.onBusy(); >>>> } >>>> >>>> @Override >>>> public void onFailure(LiveException cause) { >>>> log.debug("OnFailure(...)' - " + telefonata.getId()); >>>> telefonata.onFailure(); >>>> } >>>> >>>> } >>>> >>>> My dialplan: >>>> >>>> [test] >>>> exten => s,1,Answer() >>>> exten => s,1,Playback(smt) >>>> exten => 3,n,Set(variable=This is the value of the >>>> variable) >>>> exten => s,n,Hangup() >>>> >>>> I've a PropertyChangeListener so I can know when >>>> the call hangup. I'd like to get the value of the >>>> variable into Javacode in my method >>>> onHangupEvent(), so when the call end I need to >>>> read that variable. >>>> I know that I can create a class that extends >>>> BaseAgiScript to get the variable, but there is >>>> another way to do this? Would be more convenient to >>>> have the variable in the method onHangupEvent() for >>>> my case. >>>> >>>> Thanks >>>> >>>> >>>> 2013/8/5 Yves A. <yv...@gm... >>>> <mailto:yv...@gm...>> >>>> >>>> why do most people always think, one could >>>> "guess" their code, settings and environment >>>> that causes trouble? >>>> >>>> every access to a channel lead to an exception, >>>> if the channel is already hung up. >>>> if you need access to your channelvariables >>>> after hangup, you have to go another way... >>>> varsetevent and a local static map may be your >>>> friends here. >>>> >>>> of course there exists the h extensions which >>>> you could use to call another agi after hangup, >>>> but as i wrote before... i have no >>>> idea what your objective is, nor do i have any >>>> code to comment on... >>>> >>>> yves >>>> >>>> >>>> Am 05.08.2013 13:00, schrieb Daniele Renda: >>>>> Hi, >>>>> I need to read a variable that I set from >>>>> dialplan after i receive the onHangupEvent() >>>>> on OriginateAsync. >>>>> But I've an exception because Asterisk Java >>>>> don't find anymore the channels because is >>>>> hanged up I guess. >>>>> >>>>> So, there is another way to get the variable >>>>> in Java before the call ends? >>>>> >>>>> Thanks very much! >>>>> >>>>> -- >>>>> Daniele Renda >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Get your SQL database under version control now! >>>>> Version control is standard for application code, but databases havent >>>>> caught up. So what steps can you take to put your SQL databases under >>>>> version control? Why should you start doing it? Read more to find out. >>>>> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk >>>>> >>>>> >>>>> _______________________________________________ >>>>> Asterisk-java-users mailing list >>>>> Ast...@li... <mailto:Ast...@li...> >>>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Get your SQL database under version control now! >>>> Version control is standard for application >>>> code, but databases havent >>>> caught up. So what steps can you take to put >>>> your SQL databases under >>>> version control? Why should you start doing it? >>>> Read more to find out. >>>> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk >>>> _______________________________________________ >>>> Asterisk-java-users mailing list >>>> Ast...@li... >>>> <mailto:Ast...@li...> >>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >>>> >>>> >>>> >>>> >>>> -- >>>> Daniele Renda >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Get your SQL database under version control now! >>>> Version control is standard for application code, but databases havent >>>> caught up. So what steps can you take to put your SQL databases under >>>> version control? Why should you start doing it? Read more to find out. >>>> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk >>>> >>>> >>>> _______________________________________________ >>>> Asterisk-java-users mailing list >>>> Ast...@li... <mailto:Ast...@li...> >>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >>> >>> >>> ------------------------------------------------------------------------------ >>> Get your SQL database under version control now! >>> Version control is standard for application code, >>> but databases havent >>> caught up. So what steps can you take to put your >>> SQL databases under >>> version control? Why should you start doing it? Read >>> more to find out. >>> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> Asterisk-java-users mailing list >>> Ast...@li... >>> <mailto:Ast...@li...> >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >>> >>> >>> >>> >>> -- >>> Daniele Renda >>> >>> >>> ------------------------------------------------------------------------------ >>> Get your SQL database under version control now! >>> Version control is standard for application code, but databases havent >>> caught up. So what steps can you take to put your SQL databases under >>> version control? Why should you start doing it? Read more to find out. >>> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk >>> >>> >>> _______________________________________________ >>> Asterisk-java-users mailing list >>> Ast...@li... <mailto:Ast...@li...> >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> >> >> ------------------------------------------------------------------------------ >> Get your SQL database under version control now! >> Version control is standard for application code, but >> databases havent >> caught up. So what steps can you take to put your SQL >> databases under >> version control? Why should you start doing it? Read more >> to find out. >> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> <mailto:Ast...@li...> >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> >> >> >> >> -- >> Daniele Renda >> >> >> ------------------------------------------------------------------------------ >> Get your SQL database under version control now! >> Version control is standard for application code, but databases havent >> caught up. So what steps can you take to put your SQL databases under >> version control? Why should you start doing it? Read more to find out. >> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk >> >> >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... <mailto:Ast...@li...> >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > ------------------------------------------------------------------------------ > Get your SQL database under version control now! > Version control is standard for application code, but > databases havent > caught up. So what steps can you take to put your SQL > databases under > version control? Why should you start doing it? Read more to > find out. > http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > -- > Daniele Renda > > > > > -- > Daniele Renda > > > ------------------------------------------------------------------------------ > Get 100% visibility into Java/.NET code with AppDynamics Lite! > It's a free troubleshooting tool designed for production. > Get down to code-level detail for bottlenecks, with <2% overhead. > Download for free and get started troubleshooting in minutes. > http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk > > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |