Re: [Asterisk-java-users] Reading a variable after call ends
Brought to you by:
srt
From: Daniele R. <dan...@gm...> - 2013-08-05 12:29:31
|
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...> > 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 lis...@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... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > -- Daniele Renda |