asterisk-java-users Mailing List for Asterisk-Java Library (Page 174)
Brought to you by:
srt
You can subscribe to this list here.
2005 |
Jan
|
Feb
(8) |
Mar
(33) |
Apr
(36) |
May
(19) |
Jun
(21) |
Jul
(53) |
Aug
(30) |
Sep
(36) |
Oct
(34) |
Nov
(43) |
Dec
(72) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(123) |
Feb
(75) |
Mar
(86) |
Apr
(46) |
May
(41) |
Jun
(29) |
Jul
(76) |
Aug
(38) |
Sep
(39) |
Oct
(68) |
Nov
(16) |
Dec
(17) |
2007 |
Jan
(34) |
Feb
(18) |
Mar
(39) |
Apr
(30) |
May
(20) |
Jun
(10) |
Jul
(59) |
Aug
(54) |
Sep
(60) |
Oct
(22) |
Nov
(14) |
Dec
(10) |
2008 |
Jan
(34) |
Feb
(67) |
Mar
(65) |
Apr
(67) |
May
(60) |
Jun
(51) |
Jul
(88) |
Aug
(75) |
Sep
(47) |
Oct
(143) |
Nov
(54) |
Dec
(42) |
2009 |
Jan
(46) |
Feb
(80) |
Mar
(162) |
Apr
(159) |
May
(200) |
Jun
(34) |
Jul
(46) |
Aug
(59) |
Sep
(5) |
Oct
(35) |
Nov
(73) |
Dec
(30) |
2010 |
Jan
(23) |
Feb
(50) |
Mar
(8) |
Apr
(24) |
May
(19) |
Jun
(49) |
Jul
(56) |
Aug
(35) |
Sep
(26) |
Oct
(79) |
Nov
(39) |
Dec
(34) |
2011 |
Jan
(27) |
Feb
(22) |
Mar
(28) |
Apr
(12) |
May
(16) |
Jun
(19) |
Jul
(1) |
Aug
(64) |
Sep
(19) |
Oct
(11) |
Nov
(17) |
Dec
(12) |
2012 |
Jan
(6) |
Feb
(8) |
Mar
(15) |
Apr
(43) |
May
(41) |
Jun
(14) |
Jul
(32) |
Aug
(3) |
Sep
(4) |
Oct
(7) |
Nov
(11) |
Dec
(11) |
2013 |
Jan
(35) |
Feb
(11) |
Mar
(23) |
Apr
(25) |
May
(37) |
Jun
(47) |
Jul
(25) |
Aug
(21) |
Sep
|
Oct
(1) |
Nov
(9) |
Dec
|
2014 |
Jan
(26) |
Feb
(2) |
Mar
(18) |
Apr
(41) |
May
(7) |
Jun
(7) |
Jul
(24) |
Aug
(5) |
Sep
(6) |
Oct
(8) |
Nov
(9) |
Dec
(7) |
2015 |
Jan
(7) |
Feb
(15) |
Mar
(8) |
Apr
(12) |
May
(7) |
Jun
|
Jul
|
Aug
(5) |
Sep
(1) |
Oct
(3) |
Nov
(30) |
Dec
(3) |
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
(4) |
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Peter H. <pe...@li...> - 2005-07-16 17:18:47
|
Stefan, Thanks for the response.. Before I continue, I should mention that I'm using the 0.10 release and asterisk 1.0.9 - in case that throws up any flags. Also, I am running the manager API from a remote machine at the moment. The Manager API gets logged off in under 10 minutes. It seems to be pretty consistent at 7 minutes, but I can't get an exact snapshot of the time. The manager API doesn't seem to get notified that it is logged off. This is what is seen on the asterisk server side using the option -vvvc: == Parsing '/etc/asterisk/manager.conf': Found == Manager 'pdc' logged on from xx.xx.xx.xx == Manager 'pdc' logged off from xx.xx.xx.xx This is my log on the manager side. 2005-07-16 09:21:13,546 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connecting to yy.yy.yy.yy port 5038 net.sf.asterisk.manager.event.ConnectEvent: dateReceived=Sat Jul 16 09:21:33 PDT 2005; systemHashcode=24670264 2005-07-16 09:21:33,484 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connected via Asterisk Call Manager/1.0 2005-07-16 09:21:33,828 net.sf.asterisk.manager.DefaultManagerConnection INFO - Successfully logged in I've set the logging level to DEBUG, but nothing interesting came up. As I mentioned, it doesn't seem to know that it's gotten logged off. I'm using really basic java code to establish the connection: ManagerConnectionFactory factory = new ManagerConnectionFactory(); ManagerConnection managerConnection = factory.getManagerConnection("yy.yy.yy.yy", "username", "secret"); ManagerConnection managerConnection.login(); // Do nothing and wait On the same topic, there is another issue that presents itself when the manager is in this state. When I send a subsequent action, the Manager will reconnect, but the action will always timeout. I've set the timeout value on the action to an arbitrarily high amount. However, the action will always time out when sent in this state. 2005-07-16 09:58:09,453 net.sf.asterisk.manager.impl.ManagerReaderImpl INFO - IOException while reading from asterisk server, terminating reader thread: Connect 2005-07-16 09:58:09,453 net.sf.asterisk.manager.DefaultManagerConnection INFO - Closing socket. 2005-07-16 09:58:09,515 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connecting to 63.198.100.59 port 5038 2005-07-16 09:58:29,062 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connected via Asterisk Call Manager/1.0 2005-07-16 09:58:29,265 net.sf.asterisk.manager.DefaultManagerConnection INFO - Successfully logged in 2005-07-16 09:58:29,265 net.sf.asterisk.manager.DefaultManagerConnection INFO - Successfully reconnected. Exception in thread "main" net.sf.asterisk.manager.TimeoutException: Timeout waiting for response to Originate at net.sf.asterisk.manager.DefaultManagerConnection.sendAction(DefaultManagerConnection.java:421) at net.pdc.asterisk.Test.run(Test.java:93) at net.pdc.asterisk.Test.main(Test.java:200) I've attached the entire log file. Peter |
From: Stefan R. <sr...@re...> - 2005-07-16 12:03:39
|
> However, I noticed that my Manager API logs off the asterisk server > after a certain amount of time. hmm what amout of time? > Is there a setting on the Asterisk server that logs off a manager API > connection after it is idle? In the case Asterisk-Java gets disconnected for whatever reason it will automatically reconnect... =20 > Is this a setting in the manager API class? No, autoreconnect is a basic feature of the ManagerConnection. What you can configure is if Asterisk-Java should also try to reconnect when authentication fails. That is disabled by default and can be enabled by using DefaultManagerConnection's setKeepAliveAfterAuthenticationFailure() method. > I could find references to this subject in either documentation, nor > in the archives. > =20 > I'm hoping to set up the Manager API server so it only needs to log in > once, and listen to events for the duration it is running. Thats the way it should work ;) To help you regarding this issue I need some further information. Please enable logging and send me the logs. The best way to do this is to include the log4j jar in your classpath along with log4.properties file that might look like this: log4j.rootCategory=3DINFO, File log4j.appender.File =3D org.apache.log4j.FileAppender log4j.appender.File.file =3D asterisk-java.log log4j.appender.File.append =3D false log4j.appender.File.layout =3D org.apache.log4j.PatternLayout log4j.appender.File.layout.ConversionPattern =3D %d %c %p - %m\n =3DStefan |
From: Stefan R. <sr...@re...> - 2005-07-16 11:52:26
|
On Fri, 2005-07-15 at 22:34 -0300, dovb wrote: > Actually, at home I am using AsteriskWin32, since here I have a > Windows-based machine... > It is supposed to emulate Asterisk 1.0.7 over Cygwin. > Is it possible that AsteriskWin32 doesn't behave well? I don't have any experience with Asterisk on the Windows platform. > I'll test my code at the office to see whether it would work on a Linux > Red Hat machine! That sounds like a good idea so we can nail down the problem either to AsteriskWin32 or Asterisk-Java. =3DStefan |
From: dovb <do...@te...> - 2005-07-16 01:34:19
|
Hi Stephan, Thanks for the reply. Actually, at home I am using AsteriskWin32, since here I have a Windows-based machine... It is supposed to emulate Asterisk 1.0.7 over Cygwin. The correction you made was a mistake of mine when I copied the code to the email, but the issue I have is the following... On AGI Server console I see the following: cc0 cc1 15/07/2005 22:29:41 net.sf.asterisk.util.impl.JavaLoggingLog error SEVERE: AGIException while handling request: Unable to read reply from Asterisk: Connection reset While on Asterisk console, nothing special -- Executing AGI("SIP/dov.bigio-5972", "agi://localhost/TrataAGI.agi") in new stack -- Playing 'digits/1' (language 'en') -- Playing 'digits/2' (language 'en') -- Playing 'digits/3' (language 'en') And no error at all, even with verbose = 10 and debug = 10. Is it possible that AsteriskWin32 doesn't behave well? I'll test my code at the office to see whether it would work on a Linux Red Hat machine! Thank you Dov --- Date: Thu, 14 Jul 2005 12:52:39 -0000 (UTC) Subject: Re: [Asterisk-java-users] Help about agi server From: "Stefan Reuter" <sr...@re...> To: ast...@li... Reply-To: ast...@li... Hi Dov, what version of Asterisk do you use? can you post the relevant section of your asterisk console (use set verbose 9 to enable full output)? When I run your AGI script and press '123#' the channel is hung up at SayDigitsCommand sc =3D new SayDigitsCommand(result); because: -- Playing 'digits/1' (language 'en') -- Playing 'digits/2' (language 'en') -- Playing 'digits/3' (language 'en') Jul 14 20:47:43 WARNING[801]: file.c:475 ast_openstream: File digits/# does not exist in any format Jul 14 20:47:43 WARNING[801]: file.c:779 ast_streamfile: Unable to open digits/# (format alaw): No such file or directory so I had to change that to new SayDigitsCommand(result.substring(0, result.length() - 1)); after that everything went fine. =3DStefan > Hi, > > I have the following simple code: > > After printing "cc1" (after I dial 123) the AGIServer prints > > 13/07/2005 23:28:05 net.sf.asterisk.util.impl.JavaLoggingLog error > SEVERE: AGIException while handling request: Unable to read reply from > Asterisk: Connectio > n reset > > and stops running. > > Where am I going wrong??? > > Thank you! > Dov > > > public class TrataAGI extends AbstractAGIScript > { > public void service(AGIRequest request, AGIChannel channel) throws > AGIException > { > // Answer the channel... > answer(channel); > > // ...say hello... > > String result =3D getNumber(channel); > SayDigitsCommand sc =3D new SayDigitsCommand(result); > System.out.println("aa" + result); > AGIReply rep =3D channel.sendCommand(sc); > System.out.println("bb" + result); > > if (result.substring(0, result.length() - 1).equals("123")) > { > System.out.println("cc0"); > SayNumberCommand cmd =3D new SayNumberCommand(new > Integer("123").toString()); > System.out.println("cc1"); > rep =3D channel.sendCommand(cmd); > System.out.println("cc2"); > } > > if (result.substring(0, result.length() - 1).equals("456")) > { > System.out.println("dd0"); > SayNumberCommand cmd =3D new SayNumberCommand(new > Integer("456").toString()); > System.out.println("dd1"); > rep =3D channel.sendCommand(cmd); > System.out.println("dd2"); > SayNumberCommand snc =3D new SayNumberCommand("11"); > System.out.println("dd3"); > rep =3D channel.sendCommand(snc); > System.out.println("dd4"); > } > > // ...and hangup. > hangup(channel); > } > > private String getNumber(AGIChannel channel) > { > String lido =3D ""; > AGIReply reply =3D null; > StringBuffer result =3D new StringBuffer(); > while (!lido.equals("#")) > { > WaitForDigitCommand wc =3D new WaitForDigitCommand(); > try > { > reply =3D channel.sendCommand(wc); > } > catch (AGIException e) > { > e.printStackTrace(); > System.exit(0); > } > > String resp =3D (String) reply.getResult(); > int number =3D new Integer(resp).intValue(); > char c =3D (char) number; > lido =3D new Character(c).toString(); > result.append(lido); > } > return (result.toString()); > } > |
From: Peter H. <pe...@li...> - 2005-07-16 01:18:05
|
Hi All, I'm new to asterisk and java/asterisk. I've been playing around with it = for about 2 days now.. I've successfully used the Manager API to login, = and perform some asterisk actions. However, I noticed that my Manager API logs off the asterisk server = after a certain amount of time. Is there a setting on the Asterisk server that logs off a manager API = connection after it is idle? Is this a setting in the manager API class? I could find references to this subject in either documentation, nor in = the archives. I'm hoping to set up the Manager API server so it only needs to log in = once, and listen to events for the duration it is running. I'd appreciate any insight into this. Thanks, Peter Hsu |
From: Stefan R. <sr...@re...> - 2005-07-15 10:20:52
|
>> I understand... so we need to fix this to work with Asterisk 1.0.x and >> the upcoming 1.2 (with QueueStatusCompeleteEvent) is suppose, right? > > Hm, nah, I can just react to all incoming queue related events and refe= sh > my > own visualization of the queues and just generally hold off queue relat= ed > activities for a few seconds. I think that a little delay is no big dea= l > at all. Ok that's fine. One thing I still remain unsure about is Asterisk-Java's dependency on specific Asterisk versions. When using the ManagerConnection or AGI thats currently no big deal as I don't expect much change regarding Asterisk's basic concepts in that area= . When new ManagerActions or AGICommands are added I usually try to include a note about since which version of Asterisk it is available, so that should be fine. But with the AsteriskManager things are different, here we have a few options: 1. Support only the lowest common denominator 2. Latest Asterisk-Java supports latest Asterisk (i.e. Asterisk 1.0.x -> Asterisk-Java 0.1, Asterisk 1.2 -> Asterisk-Java 0.2) and so on 3. Latest Asterisk-Java supports multiple versions of Asterisk (i.e. if (astversion =3D 1.0.x) then use this construct else use that construct) Option 1 is bad as we are stuck with the old deficiencies of early Asterisk versions. Option 2 means supporting multiple Asterisk-Java branches, but the users who don't want to upgrade their Asterisk servers probably prefer to stick with the version of Asterisk-Java that once went through their QA, too. Option 3 will sooner or later become a maintainance nightmare for me ;) What do you think? Is Option 2 ok? How much support (bugfixes, ..) do you need for older releases? > So far I like Asterisk-Java very much, it hasn't really done anything > weird (aka. bugs) at all, which is IMHO very nice. :) Thats nice to hear! > Haven't figured out how to put a call on hold yet, but I think > SetVarAction with the proper magic could do it. > There is no CLI command to do it either. Need to do some experiments. Hmm i don't know either. if you got a solution let us know. =3DStefan |
From: Stefan R. <sr...@re...> - 2005-07-15 09:40:23
|
> very nice and very enlightening :) I have found some minor typos, and a= s > i have enough of them in my own documents i don't want to keep them :) > > So here is a patch file for design.xml. I hope my changes are ok :) Thanks a lot. I applied the patch and regenerated the website. =3DStefan |
From: Tobias W. <tob...@ev...> - 2005-07-15 08:27:53
|
Hi, Stefan Reuter schrieb: > as there were several questions regarding Asterisk-Java's design i wrote > a small design document that should provide an overview of the library. > It is available online at > http://asterisk-java.sourceforge.net/design.html very nice and very enlightening :) I have found some minor typos, and as i have enough of them in my own documents i don't want to keep them :) So here is a patch file for design.xml. I hope my changes are ok :) So long, Tobias |
From: Jan E. <jan...@pl...> - 2005-07-15 08:15:12
|
On Thursday 14 July 2005 10:55, Stefan Reuter wrote: > > Doesn't the StatusComplete come before the Queue events event have > > started to > > arrive, so thus when they come initialized==true and the events are not > > handled internally at all but just dispatched to other registered event > > handlers. That's my interpretation of the 0.1 code. > > You are right, the problem is indeed if the StatusCompleteEvent is > received before the QueueEvents have been processed they are ignored. > > > If Asterisk sends out the responses sequentially, ie all Status events > > before > > the Queue events are even started on, it might work to reorder the two > > actions (send QueueStatusAction before StatusAction) or to just send a > > third > > dummy action that would act as the "we're done with queues" marker. This > > may > > be a naive interpretation of how Asterisk works though... > > The events are sent out asynchronously, I think you will even get mixed > Status and QueueEvents but I didn't verify that yet. Ok, that rules out the idea of checking stuff based on arrival sequence. It would have been a really simple fix. > The clean solution is the QueueStatusCompleteEvent. Yesterday I submitted > a patch regarding this (http://bugs.digium.com/view.php?id=4694), so now > we have it in CVS-HEAD asterisk at least. Seems this was an ackowledged problem and the Digium folks just waited for a fix to it. So the next Asterisk version will have this fixed, although it'll take a while before we upgrade, the changes are AFAIK quite large. > For the 1.0.x Asterisk one solution might be just to wait for a few > seconds at startup and asume the initial state to be received then. > > > Yes, but then when AsteriskManager handles queues internally I end up > > with the > > same code duplicated in two places, ie. Asterisk-Java Queue:s and my own > > Queue:s, both doing basically the same thing but with optionally > > different names. That I'd rather want to avoid > > I understand... so we need to fix this to work with Asterisk 1.0.x and the > upcoming 1.2 (with QueueStatusCompeleteEvent) is suppose, right? Hm, nah, I can just react to all incoming queue related events and refesh my own visualization of the queues and just generally hold off queue related activities for a few seconds. I think that a little delay is no big deal at all. So far I like Asterisk-Java very much, it hasn't really done anything weird (aka. bugs) at all, which is IMHO very nice. :) Haven't figured out how to put a call on hold yet, but I think SetVarAction with the proper magic could do it. There is no CLI command to do it either. Need to do some experiments. -- Jan Ekholm jan...@pl... |
From: Stefan R. <sr...@re...> - 2005-07-14 12:52:51
|
Hi Dov, what version of Asterisk do you use? can you post the relevant section of your asterisk console (use set verbose 9 to enable full output)? When I run your AGI script and press '123#' the channel is hung up at SayDigitsCommand sc =3D new SayDigitsCommand(result); because: -- Playing 'digits/1' (language 'en') -- Playing 'digits/2' (language 'en') -- Playing 'digits/3' (language 'en') Jul 14 20:47:43 WARNING[801]: file.c:475 ast_openstream: File digits/# does not exist in any format Jul 14 20:47:43 WARNING[801]: file.c:779 ast_streamfile: Unable to open digits/# (format alaw): No such file or directory so I had to change that to new SayDigitsCommand(result.substring(0, result.length() - 1)); after that everything went fine. =3DStefan > Hi, > > I have the following simple code: > > After printing "cc1" (after I dial 123) the AGIServer prints > > 13/07/2005 23:28:05 net.sf.asterisk.util.impl.JavaLoggingLog error > SEVERE: AGIException while handling request: Unable to read reply from > Asterisk: Connectio > n reset > > and stops running. > > Where am I going wrong??? > > Thank you! > Dov > > > public class TrataAGI extends AbstractAGIScript > { > public void service(AGIRequest request, AGIChannel channel) throws > AGIException > { > // Answer the channel... > answer(channel); > > // ...say hello... > > String result =3D getNumber(channel); > SayDigitsCommand sc =3D new SayDigitsCommand(result); > System.out.println("aa" + result); > AGIReply rep =3D channel.sendCommand(sc); > System.out.println("bb" + result); > > if (result.substring(0, result.length() - 1).equals("123")) > { > System.out.println("cc0"); > SayNumberCommand cmd =3D new SayNumberCommand(new > Integer("123").toString()); > System.out.println("cc1"); > rep =3D channel.sendCommand(cmd); > System.out.println("cc2"); > } > > if (result.substring(0, result.length() - 1).equals("456")) > { > System.out.println("dd0"); > SayNumberCommand cmd =3D new SayNumberCommand(new > Integer("456").toString()); > System.out.println("dd1"); > rep =3D channel.sendCommand(cmd); > System.out.println("dd2"); > SayNumberCommand snc =3D new SayNumberCommand("11"); > System.out.println("dd3"); > rep =3D channel.sendCommand(snc); > System.out.println("dd4"); > } > > // ...and hangup. > hangup(channel); > } > > private String getNumber(AGIChannel channel) > { > String lido =3D ""; > AGIReply reply =3D null; > StringBuffer result =3D new StringBuffer(); > while (!lido.equals("#")) > { > WaitForDigitCommand wc =3D new WaitForDigitCommand(); > try > { > reply =3D channel.sendCommand(wc); > } > catch (AGIException e) > { > e.printStackTrace(); > System.exit(0); > } > > String resp =3D (String) reply.getResult(); > int number =3D new Integer(resp).intValue(); > char c =3D (char) number; > lido =3D new Character(c).toString(); > result.append(lido); > } > return (result.toString()); > } > |
From: Stefan R. <sr...@re...> - 2005-07-14 07:56:00
|
> Doesn't the StatusComplete come before the Queue events event have star= ted > to > arrive, so thus when they come initialized=3D=3Dtrue and the events are= not > handled internally at all but just dispatched to other registered event > handlers. That's my interpretation of the 0.1 code. You are right, the problem is indeed if the StatusCompleteEvent is received before the QueueEvents have been processed they are ignored. > If Asterisk sends out the responses sequentially, ie all Status events > before > the Queue events are even started on, it might work to reorder the two > actions (send QueueStatusAction before StatusAction) or to just send a > third > dummy action that would act as the "we're done with queues" marker. Thi= s > may > be a naive interpretation of how Asterisk works though... The events are sent out asynchronously, I think you will even get mixed Status and QueueEvents but I didn't verify that yet. The clean solution is the QueueStatusCompleteEvent. Yesterday I submitted a patch regarding this (http://bugs.digium.com/view.php?id=3D4694), so no= w we have it in CVS-HEAD asterisk at least. For the 1.0.x Asterisk one solution might be just to wait for a few seconds at startup and asume the initial state to be received then. > Yes, but then when AsteriskManager handles queues internally I end up w= ith > the > same code duplicated in two places, ie. Asterisk-Java Queue:s and my ow= n > Queue:s, both doing basically the same thing but with optionally differ= ent > names. That I'd rather want to avoid I understand... so we need to fix this to work with Asterisk 1.0.x and th= e upcoming 1.2 (with QueueStatusCompeleteEvent) is suppose, right? =3DStefan |
From: dovb <do...@te...> - 2005-07-14 02:30:12
|
Hi, I have the following simple code: After printing "cc1" (after I dial 123) the AGIServer prints 13/07/2005 23:28:05 net.sf.asterisk.util.impl.JavaLoggingLog error SEVERE: AGIException while handling request: Unable to read reply from Asterisk: Connectio n reset and stops running. Where am I going wrong??? Thank you! Dov public class TrataAGI extends AbstractAGIScript { public void service(AGIRequest request, AGIChannel channel) throws AGIException { // Answer the channel... answer(channel); // ...say hello... String result = getNumber(channel); SayDigitsCommand sc = new SayDigitsCommand(result); System.out.println("aa" + result); AGIReply rep = channel.sendCommand(sc); System.out.println("bb" + result); if (result.substring(0, result.length() - 1).equals("123")) { System.out.println("cc0"); SayNumberCommand cmd = new SayNumberCommand(new Integer("123").toString()); System.out.println("cc1"); rep = channel.sendCommand(cmd); System.out.println("cc2"); } if (result.substring(0, result.length() - 1).equals("456")) { System.out.println("dd0"); SayNumberCommand cmd = new SayNumberCommand(new Integer("456").toString()); System.out.println("dd1"); rep = channel.sendCommand(cmd); System.out.println("dd2"); SayNumberCommand snc = new SayNumberCommand("11"); System.out.println("dd3"); rep = channel.sendCommand(snc); System.out.println("dd4"); } // ...and hangup. hangup(channel); } private String getNumber(AGIChannel channel) { String lido = ""; AGIReply reply = null; StringBuffer result = new StringBuffer(); while (!lido.equals("#")) { WaitForDigitCommand wc = new WaitForDigitCommand(); try { reply = channel.sendCommand(wc); } catch (AGIException e) { e.printStackTrace(); System.exit(0); } String resp = (String) reply.getResult(); int number = new Integer(resp).intValue(); char c = (char) number; lido = new Character(c).toString(); result.append(lido); } return (result.toString()); } |
From: Jan E. <jan...@pl...> - 2005-07-13 06:38:38
|
On Wednesday 13 July 2005 09:18, Stefan Reuter wrote: > Hi Jan, > > > I noticed that DefaultAsteriskManager does handle queues too, or at least > > it has the stubs for it in 0.1. However, as the flag queuesInitialized is > > always true > > DefaultAsteriskManager requests Channel and Queue state at startup. To > do this it sends a StatusAction and a QueueStatusAction. > Until that initial state is received it queues any state changing events > to apply them as delta to the initial state later on. > The StatusAction results in a StatusEvents being sent for every active > channel. Asterisk indicates that all StatusEvents have been sent by > sending a StatusCompleteEvent. So when DefaultAsteriskManager receives a > StatusCompleteEvent it knows that the initial channel state has been > completely received (now channelsInitialized == true). > Unfortunatly the QueueStatusAction does not result in a > QueueStatusComplete event being sent, so it never knows whether queue > state is completely received. Therefore the hack to set it to true at > startup. This will work most of the time, but might cause trouble when > receiving queue changing events while still evaluating the results of > the QueueStatusAction. Doesn't the StatusComplete come before the Queue events event have started to arrive, so thus when they come initialized==true and the events are not handled internally at all but just dispatched to other registered event handlers. That's my interpretation of the 0.1 code. I have a few test queues and I see that the events for the queues get sent and contain proper data. If Asterisk sends out the responses sequentially, ie all Status events before the Queue events are even started on, it might work to reorder the two actions (send QueueStatusAction before StatusAction) or to just send a third dummy action that would act as the "we're done with queues" marker. This may be a naive interpretation of how Asterisk works though... > > then the queues never get handled by DefaultAsteriskManager.handleEvent > > and the events are instead sent to event handlers directly. > > They are handled and with the limititation above it works fine. > > > Of course I can > > do the handling manually, but as the code already seems to be in place in > > DefaultAsteriskManager I'd like to use that code and not build my own > > framework on top of it. So call me lazy. :) > > Another option is to just fix DefaultAsteriskManager where it might be > broken and submit a patch. So you get free maintainance for that part in > the future :) Yup, that's an option too. > > Of course, if DefaultAsteriskManager one day starts to handle the > > events then my own code is left cold in the water. > > No, your code will always work. At least if you registered your event > handler independently with the underlying ManagerConnection. > In this case you always receive every event regardless of what > DefaultAsteriskManager does with that event. Yes, but then when AsteriskManager handles queues internally I end up with the same code duplicated in two places, ie. Asterisk-Java Queue:s and my own Queue:s, both doing basically the same thing but with optionally different names. That I'd rather want to avoid. Regards, Jan Ekholm -- Jan Ekholm jan...@pl... |
From: Stefan R. <sr...@re...> - 2005-07-13 06:19:13
|
Hi Jan, > I noticed that DefaultAsteriskManager does handle queues too, or at least= it=20 > has the stubs for it in 0.1. However, as the flag queuesInitialized is al= ways=20 > true DefaultAsteriskManager requests Channel and Queue state at startup. To do this it sends a StatusAction and a QueueStatusAction. Until that initial state is received it queues any state changing events to apply them as delta to the initial state later on. The StatusAction results in a StatusEvents being sent for every active channel. Asterisk indicates that all StatusEvents have been sent by sending a StatusCompleteEvent. So when DefaultAsteriskManager receives a StatusCompleteEvent it knows that the initial channel state has been completely received (now channelsInitialized =3D=3D true). Unfortunatly the QueueStatusAction does not result in a QueueStatusComplete event being sent, so it never knows whether queue state is completely received. Therefore the hack to set it to true at startup. This will work most of the time, but might cause trouble when receiving queue changing events while still evaluating the results of the QueueStatusAction. > then the queues never get handled by DefaultAsteriskManager.handleEvent=20 > and the events are instead sent to event handlers directly.=20 They are handled and with the limititation above it works fine. > Of course I can=20 > do the handling manually, but as the code already seems to be in place in= =20 > DefaultAsteriskManager I'd like to use that code and not build my own=20 > framework on top of it. So call me lazy. :) Another option is to just fix DefaultAsteriskManager where it might be broken and submit a patch. So you get free maintainance for that part in the future :) > Of course, if DefaultAsteriskManager one day starts to handle the=20 > events then my own code is left cold in the water. No, your code will always work. At least if you registered your event handler independently with the underlying ManagerConnection. In this case you always receive every event regardless of what DefaultAsteriskManager does with that event. So have a look at it and decide whether it works for you. I will check if there is a QueueStatusComplete event in Asterisk CVS-HEAD and maybe submit a patch to Digium if there isn't. Cheers, Stefan |
From: Jan E. <jan...@pl...> - 2005-07-13 05:43:58
|
Hi, I noticed that DefaultAsteriskManager does handle queues too, or at least it has the stubs for it in 0.1. However, as the flag queuesInitialized is always true then the queues never get handled by DefaultAsteriskManager.handleEvent and the events are instead sent to event handlers directly. Of course I can do the handling manually, but as the code already seems to be in place in DefaultAsteriskManager I'd like to use that code and not build my own framework on top of it. So call me lazy. :) Of course, if DefaultAsteriskManager one day starts to handle the events then my own code is left cold in the water. Any hints how to proceed? Best regards, Jan Ekholm -- Jan Ekholm jan...@pl... |
From: Jan E. <jan...@pl...> - 2005-07-13 05:37:17
|
On Monday 11 July 2005 22:50, Stefan Reuter wrote: > Hi, > > as there were several questions regarding Asterisk-Java's design i wrote > a small design document that should provide an overview of the library. > It is available online at > http://asterisk-java.sourceforge.net/design.html Well, this is a very good document. I learnt quite a few new things from it. Especially the class diagrams give a good overview of the relations. Good work! -- Jan Ekholm jan...@pl... |
From: Stefan R. <sr...@re...> - 2005-07-12 10:36:06
|
Hi, what you got when running your application is probably an SWTException telling you about an invalid thread access. This is neither an Asterisk-Java problem not an SWT problem. Regardless of using either Swing or SWT you are not allowed to access the GUI from another Thread than the one that created the GUI, because neithe= r Swing nur SWT widgets are thread safe. The difference is that SWT actuall= y enforces this and prevents you from doing something that is not thread safe, while Swing doesn't resulting in people having unpredictable bugs i= n their applications. Your handleEvent() is invoked by Asterisk-Java's event handling thread an= d must therefore not access any widgets directly. The solution to your problem is to use the asyncExec() method of Display: [...] public void handleEvent(ManagerEvent event) { if ( (event instanceof DialEvent)) { DialEvent dial =3D (DialEvent) event; final List list =3D eventList; final String text =3D "Caller ID:" + dial.getCallerId(); eventList.getDisplay().asyncExec(new Runnable() { public void run() { list.add(text); } }); } } [...] Note that the variables you want to access within the inner class must be declared final. Hope that helps =3DStefan |
From: liyuqian <liy...@95...> - 2005-07-12 04:00:33
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Hi, stefan<br> <br> I try write a application in eclipse, but i can't apply asterisk-java event to SWT widgets(ie. List).<br> <br> For example: <br> .................<br> import <b>org.eclipse.swt.widgets.List<br> </b>..................<br> List eventList = new List();<br> ................<br> public void handleEvent(ManagerEvent event) {<br> if ( (event instanceof DialEvent)) {<br> DialEvent dial = (DialEvent) event;<br> eventList.add("Caller ID:" + dial.getCallerId());<br> ...........<br> }<br> ..............<br> <br> Above code can't work in SWT widgets, but work fine in SWING.<br> <br> Is SWT events and SWING events different? How i can do if i want use asterisk-java in SWT widgets?<br> <br> Sorry my english.<br> <br> Thanks.<br> </body> </html> |
From: Stefan R. <sr...@re...> - 2005-07-11 19:51:06
|
Hi, as there were several questions regarding Asterisk-Java's design i wrote a small design document that should provide an overview of the library. It is available online at http://asterisk-java.sourceforge.net/design.html Cheers, Stefan |
From: Stefan R. <sr...@re...> - 2005-07-06 10:33:35
|
> This little brief should go in the docs somewhere, it gives a better > understanding of what is what. I missed some kind of short overview of = the > relations between the major classes. You are right! I will prepare a short design overview of Asterisk-Java so= on. > Yes, so true. I had used ManagerConnection.addEventHandler() in my firs= t > tests, but then somehow got the idea that I couldn't use it anymore onc= e I > used an AsteriskManager. Of course I can, and it works ok too. I assume > that AsteriskManager gets to handle the event before my own event handl= er > does, so the new channels etc are already in place. That's a valid question. I had a look at the source of DefaultManagerConnection and noticed that a HashSet is used to store the event handlers. Therefore with the current release it is impossible to predict which even= t handler will be notified first. I will change that to a List. Then the event handlers are called in the same order as they were added to the ManagerConnection, i.e. if you pass the ManagerConnection to DefaultAsteriskManager before adding your own event handler it will work as you described above. > Well, my application will basically do similar tasks to the Flash Opera= tor > Panel (http://www.asternic.org/), although with a very different UI. So > monitoring what is going and changing active channels/queues etc is ver= y > central. I like the action/event/response framework, it is quite handy = for > my case, especially a notification based one. Ok, then Channel and Queue state change events will work fine for you. Cheers, Stefan |
From: Jan E. <jan...@pl...> - 2005-07-06 09:59:43
|
Hi, Thank you for the quick response! See my comments below. On Wednesday 06 July 2005 12:18, Stefan Reuter wrote: > let me try to clarify the design of the Manager API of Asterisk-Java: > > The foundation is the ManagerConnection, it repesents a connection to an > Asterisk Server and is capable to send actions and receive responses and > events. It doesn't add any valuable functionality but rather provides a > "Java" view to the Manager API (freeing you from TCP/IP connection and > parsing stuff). > > The AsteriskManager is built on top of the ManagerConnection and is an > attempt to simplify interaction with Asterisk by abstracting the > interface. > You will certainly have less freedom using AsteriskManager but it will > make life easier for easy things (like originating a call or getting a > list of open channels). > AsteriskManager is still in an early state of development as I am kinda > unsure about the abstraction level that is appropriate. > So, when using AsteriskManager be aware that it might change in the future. This little brief should go in the docs somewhere, it gives a better understanding of what is what. I missed some kind of short overview of the relations between the major classes. > That said it is perfectly valid to combine ManagerConnection and > AsteriskManager in your application. > You get a ManagerConnection (from the factory, or by using spring or > whatever), register your own event handler > (ManagerConnection.addEventHandler()) and then pass the connection it to > the DefaultAsteriskManager. Yes, so true. I had used ManagerConnection.addEventHandler() in my first tests, but then somehow got the idea that I couldn't use it anymore once I used an AsteriskManager. Of course I can, and it works ok too. I assume that AsteriskManager gets to handle the event before my own event handler does, so the new channels etc are already in place. > For future releases I would like to extend the AsteriskManager and the > Domain object to perform event handling at a higher level of abstraction. > So you will be able to register a handler to be notified about new > Channels (or Calls?) and you will be able to register with the instance of > the domain object (say a specific Channel or Queue) to be informed about > changes of that particular object (a Channel being hung up or an Agent > joining a Queue). This sounds like a good idea. As a lazy programmer I like higher level abstractions. > If you'd like to provide some information about the application you are > building and the kind of events you need that will be valuable input. Well, my application will basically do similar tasks to the Flash Operator Panel (http://www.asternic.org/), although with a very different UI. So monitoring what is going and changing active channels/queues etc is very central. I like the action/event/response framework, it is quite handy for my case, especially a notification based one. Best regards, Jan Ekholm -- Jan Ekholm jan...@pl... |
From: Stefan R. <sr...@re...> - 2005-07-06 09:18:25
|
Hi Jan, let me try to clarify the design of the Manager API of Asterisk-Java: The foundation is the ManagerConnection, it repesents a connection to an Asterisk Server and is capable to send actions and receive responses and events. It doesn't add any valuable functionality but rather provides a "Java" view to the Manager API (freeing you from TCP/IP connection and parsing stuff). The AsteriskManager is built on top of the ManagerConnection and is an attempt to simplify interaction with Asterisk by abstracting the interface. You will certainly have less freedom using AsteriskManager but it will make life easier for easy things (like originating a call or getting a list of open channels). AsteriskManager is still in an early state of development as I am kinda unsure about the abstraction level that is appropriate. So, when using AsteriskManager be aware that it might change in the futur= e. That said it is perfectly valid to combine ManagerConnection and AsteriskManager in your application. You get a ManagerConnection (from the factory, or by using spring or whatever), register your own event handler (ManagerConnection.addEventHandler()) and then pass the connection it to the DefaultAsteriskManager. For future releases I would like to extend the AsteriskManager and the Domain object to perform event handling at a higher level of abstraction. So you will be able to register a handler to be notified about new Channels (or Calls?) and you will be able to register with the instance o= f the domain object (say a specific Channel or Queue) to be informed about changes of that particular object (a Channel being hung up or an Agent joining a Queue). If you'd like to provide some information about the application you are building and the kind of events you need that will be valuable input. Cheers, Stefan |
From: Jan E. <jan...@pl...> - 2005-07-06 08:44:55
|
Hi, I started looking at Asterisk-Java a few days ago and so far it looks like a really capable library. It has saved me from doing the low level AMI stuff manually and that's really great. I'm looking at using DefaultAsteriskManager in my test applications, and was wondering how others that use it have done the integration into their own apps. The DefaultAsteriskManager takes care of most/all(?) events behind the scenes and my application really doesn't know what a new channel is created or a hangup happens. What is the preferred way of performing this "information gathering" without constantly polling DefaultAsteriskManager? Somehow I'd like the information to progress up the food chain. One solution could be to override the event handlers in DefaultAsteriskManager that I'm interested in and then just call the method i DefaultAsteriskManager to do the real work. This isn't too good as the methods in DefaultAsteriskManager can fail silently without any trace except a log message. Also DefaultAsteriskManager doesn't handle all events sent by Asterisk, they are just logged and then ignored, and I'd optionally have to react to some of those too. Bottom line is that Asterisk-Java seems like a really nice piece of work, I just don't yet know how to use it properly. Oh, I use the 0.1 version. Best regards, Jan Ekholm -- Jan Ekholm jan...@pl... |
From: Stefan R. <sr...@re...> - 2005-07-02 07:38:55
|
On Sat, 2005-07-02 at 00:30 -0500, Michael Evans wrote: > is this the path I would take: >=20 > 1) Create AGI scripts and run an AGI server that is tied to > an extension configured on the Asterisk server > 2) Originate a call via the manager interface and then tie > the extension to this defined AGI extension >=20 > Is this true, or is there a more direct way to originate a > call from the FastAgi API? Yes thats the way i would go, too. |
From: Michael E. <mi...@gr...> - 2005-07-02 05:30:09
|
The reason I originally shied away from the FastAGI scripts is because = the tutorial implies that they are used as a response to an incoming = call. If that is true, is this the path I would take: 1) Create AGI scripts and run an AGI server that is tied to an extension = configured on the Asterisk server 2) Originate a call via the manager interface and then tie the extension = to this defined AGI extension Is this true, or is there a more direct way to originate a call from the = FastAgi API? |