Re: [Asterisk-java-users] Multithreaded AGI script
Brought to you by:
srt
From: Sebastian G. <sc...@gm...> - 2012-10-02 00:05:44
|
Hi, I want to make a dial and bee able to control from another thread some things of that call. one example: prepaid calling: 1 account for multiple phones, for each call I have to change the amount of money left on the account so every each X time I can make recalcules for all the calls and push an audio or hangup if needed…. I tried making macros, originating, and other kind of things to have a background channel that is for control with no success also. thanks best regards On Oct 1, 2012, at 6:13 PM, Yves A. <yv...@gm...> wrote: > Hi, > > you simply can´t do more than one "action" with a channel at one time... > I dont know what you try to achieve, but maybe bridging more than one > channel could help you? describe your objective more precise... just being > verbose on the channel while streaming a file cant be the thing, you really > need, i think... > > yves > > Am 01.10.2012 19:30, schrieb Sebastian Gutierrez: >>> anyone? Stefan? >>> >>> the thing is here that if I try to start a thread passing parameters so this new thread can make actions, the thread is never started until almost the end of the service procedure. >>> >>> best regards >>> >>> >>> Begin forwarded message: >>> >>>> From: Sebastian Gutierrez <sc...@gm...> >>>> Subject: Multithreaded AGI script >>>> Date: September 25, 2012 2:51:52 PM GMT-03:00 >>>> To: ast...@li... >>>> >>>> Hi, >>>> >>>> >>>> I´m using AGI scripts for the first time, I have now my server with the default AGI server and mapping via the Class Name, all that working ok. >>>> >>>> the thing is that I want to be able to make a monitor thread, that be able to append some commands also to the AGI channel. >>>> >>>> >>>> I put here an example, I want that while executing the streamFiles, the system also executes on that channel the verbose log. >>>> >>>> is this possible??? >>>> >>>> this won´t work, the monitor apparently can't intervene in the AgiChannel. >>>> >>>> >>>> >>>> for example: >>>> >>>> THE SCRIPT CLASS: >>>> >>>> @Override >>>> public void service(AgiRequest request, AgiChannel channel) throws AgiException { >>>> >>>> // Answer the channel... >>>> answer(); >>>> >>>> >>>> Monitor r = new Monitor(channel,request); >>>> new Thread(r).start(); >>>> >>>> // ...say hello... >>>> streamFile("demo-nogo"); >>>> >>>> streamFile("tt-monkeysintro"); >>>> >>>> streamFile("tt-weasels"); >>>> >>>> streamFile("demo-nogo"); >>>> >>>> // ...and hangup. >>>> hangup(); >>>> } >>>> >>>> THE MONITOR CLASS >>>> >>>> public class Monitor implements Runnable { >>>> >>>> private AgiChannel chan; >>>> private AgiRequest req; >>>> >>>> public Monitor(AgiChannel channel, AgiRequest request) { >>>> >>>> chan = channel; >>>> req = request; >>>> } >>>> >>>> >>>> >>>> @Override >>>> public void run() { >>>> while(true) >>>> { >>>> try { >>>> chan.verbose("ASYNC TEST", 1); >>>> Thread.sleep(1000); >>>> >>>> >>>> } catch (Exception ex) { >>>> Logger.getLogger(Monitor.class.getName()).log(Level.SEVERE, null, ex); >>>> } >>>> >>>> } >>>> } >>> >> >> >> >> ------------------------------------------------------------------------------ >> Got visibility? >> Most devs has no idea what their production app looks like. >> Find out how fast your code is with AppDynamics Lite. >> http://ad.doubleclick.net/clk;262219671;13503038;y? >> http://info.appdynamics.com/FreeJavaPerformanceDownload.html >> >> >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > ------------------------------------------------------------------------------ > Got visibility? > Most devs has no idea what their production app looks like. > Find out how fast your code is with AppDynamics Lite. > http://ad.doubleclick.net/clk;262219671;13503038;y? > http://info.appdynamics.com/FreeJavaPerformanceDownload.html_______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |