Thread: [Asterisk-java-users] asterisk manager can't get variable values
Brought to you by:
srt
From: Jason W. <ja...@cl...> - 2006-02-03 16:26:03
|
Hello, In the dialplan, I set the variable 'accepted=yes' when the user presses 1 and is transfered to extension 1. I'm using the following code to try and get variable values from asterisk in my java console app using the manager API: //**************************************** getVarAction = new GetVarAction(); getVarAction.setVariable("accepted"); Thread.sleep (14000); //wait ten seconds to allow the user to make a selection actionResponse = managerConnection.sendAction(getVarAction,10000); String accepted = new String(); accepted = actionResponse.getAttribute("EXTEN"); System.out.println("accepted=" + accepted); //**************************************** For Any variable I try to get, even the predefined channel variables, I get null. Help would be greatly appreciated. Jason |
From: <mar...@gm...> - 2006-02-03 19:45:28
|
I think it might a problem with the version of the package net.sf.Asterisk.= . . because when I use the method getAttribue it does not compile,.... 2006/2/3, Jason Wolfe <ja...@cl...>: > > Hello, > > In the dialplan, I set the variable 'accepted=3Dyes' when the user presse= s 1 > and is transfered to extension 1. > > I'm using the following code to try and get variable values from asterisk > in > my java console app using the manager API: > > //**************************************** > > getVarAction =3D new GetVarAction(); > getVarAction.setVariable("accepted"); > Thread.sleep (14000); //wait ten seconds to allow the user to make a > selection > actionResponse =3D managerConnection.sendAction(getVarAction,10000); > > String accepted =3D new String(); > accepted =3D actionResponse.getAttribute("EXTEN"); > System.out.println("accepted=3D" + accepted); > > //**************************************** > > For Any variable I try to get, even the predefined channel variables, I > get > null. Help would be greatly appreciated. > > Jason > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat= =3D121642 > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > -- Mar=EDa |
From: Jason W. <jas...@be...> - 2006-02-03 22:27:52
|
This is interesting... when I used the 'tutorial app' at http://www.voip-info.org/wiki/view/MANAGERAPI-JAVA-AGI I couldn't get the actuall variable value from the following code... GetVariableCommand OBJ_DIALSTATUS= new GetVariableCommand("DIALSTATUS"); String dialstatus = OBJ_DIALSTATUS.getVariable(); if(dialstatus.equals("ANSWER")) { } in the above code, getVariable returned "DIALSTATUS", not the value of DIALSTATUS, ANSWER or whatever... do you think this might have something to do with the problem... If there really is a problem. I'm fairly new to Java and very new to asterisk, so I don't want nasty comments, but I guess your right, it might not work. Surely the author of this code tested it and it worked at some point. Jason -----Original Message----- From: ast...@li... [mailto:ast...@li...]On Behalf Of María Chóliz Sent: Friday, February 03, 2006 2:45 PM To: ast...@li... Subject: Re: [Asterisk-java-users] asterisk manager can't get variable values I think it might a problem with the version of the package net.sf.Asterisk... because when I use the method getAttribue it does not compile,.... 2006/2/3, Jason Wolfe <ja...@cl...>: Hello, In the dialplan, I set the variable 'accepted=yes' when the user presses 1 and is transfered to extension 1. I'm using the following code to try and get variable values from asterisk in my java console app using the manager API: //**************************************** getVarAction = new GetVarAction(); getVarAction.setVariable("accepted"); Thread.sleep (14000); //wait ten seconds to allow the user to make a selection actionResponse = managerConnection.sendAction(getVarAction,10000); String accepted = new String(); accepted = actionResponse.getAttribute("EXTEN"); System.out.println("accepted=" + accepted); //**************************************** For Any variable I try to get, even the predefined channel variables, I get null. Help would be greatly appreciated. Jason ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ Asterisk-java-users mailing list Ast...@li... https://lists.sourceforge.net/lists/listinfo/asterisk-java-users -- María |
From: <mar...@gm...> - 2006-02-04 09:46:24
|
Hi, Jason, I have worked more with the manager_java, not with fastagi, but I think I might try to help you, or I hope so. The code you have just sent does what it should.Visit this page: http://asterisk-java.sourceforge.net/apidocs/net/sf/asterisk/fastagi/comman= d/GetVariableCommand.html see: *getVariable<http://asterisk-java.sourceforge.net/apidocs/net/sf/asterisk/= fastagi/command/GetVariableCommand.html#getVariable%28%29> *() Returns the name of the variable to retrieve. Have you tried witth actions of Manager. If you arer using a version of Asterisk under 1.2...you can set a local variable in the dialplan by using the action SetVarAction, and then getting the value with GetVarAction. Or setting the value in the dialplan and getting it with getvaraction. Getvarction only works with local variables under version 1.2 asterisk , from 1.2 it works also with global variables. I hope this helped you, good luck! |
From: Jason W. <jas...@be...> - 2006-02-04 18:10:58
|
Thanks for the help, I know I'm close, and just missing something minor. Perhaps I'm not in full understanding of how actions and responses work... I used ethereal to quickly look at the individual packets moving between my client and the asterisk server. I see that asterisk responds to my action with the value that I'm looking for. ManagerResponse actionResponse; GetVarAction getVarAction; getVarAction = new GetVarAction(); getVarAction.setVariable("CONSOLE"); actionResponse = managerConnection.sendAction(getVarAction,10000); System.out.println(actionResponse.toString()); //Why isn't the variable listed in here??? /* this is what I get from actionResponse.toSTring() net.sf.asterisk.manager.response.ManagerResponse: actionId='null'; message='null'; response='Success'; uniqueId='null'; */ String myVar = new String(); myVar = actionResponse.getVariable("CONSOLE"); // System.out.println("myVar=" + myVar); //myVar is null??? Well, if the problem isn't obvious from the code above then I guess I'm heading to the sourcecode to try and pinpoint my misunderstanding. Jason -----Original Message----- From: ast...@li... [mailto:ast...@li...]On Behalf Of María Chóliz Sent: Saturday, February 04, 2006 4:46 AM To: ast...@li... Subject: Re: [Asterisk-java-users] asterisk manager can't get variable values Hi, Jason, I have worked more with the manager_java, not with fastagi, but I think I might try to help you, or I hope so. The code you have just sent does what it should.Visit this page: http://asterisk-java.sourceforge.net/apidocs/net/sf/asterisk/fastagi/command /GetVariableCommand.html see: getVariable() Returns the name of the variable to retrieve. Have you tried witth actions of Manager. If you arer using a version of Asterisk under 1.2...you can set a local variable in the dialplan by using the action SetVarAction, and then getting the value with GetVarAction. Or setting the value in the dialplan and getting it with getvaraction. Getvarction only works with local variables under version 1.2 asterisk , from 1.2 it works also with global variables. I hope this helped you, good luck! |
From: Jason W. <jas...@be...> - 2006-02-05 02:01:18
|
I apoligize for so many posts about this subject, but I found the problem and frankly it doesn't make any sense... If I could get a comment on this I would greatly appreciate it... The following code would only out.println 'testvar=null' GetVarAction getVarAction = new GetVarAction(); getVarAction.setVariable("testvar"); ManagerResponse actionResponse = (ManagerResponse) managerConnection.sendAction(getVarAction,30000); String accepted = actionResponse.getAttribute("testvar"); System.out.println("testvar=" + accepted); using ethereal, I looked at the actual packet coming from asterisk and noticed it was in the form: Response: Success Variable: testvar Value: youGotMe So... I changed the following line in the code... //String accepted = actionResponse.getAttribute("testvar"); String accepted = actionResponse.getAttribute("value"); and suddenly, what do ya know... out.println gives 'testvar=youGotMe' so, is asterisk sending manager response in a format different than is expected by the reader? Is this something that is configurable? I am also having a similar problem parsing events.. I'm running my java console app on a windows 2000 box, and asterisk is on an FC4 box. thanks. Jason -----Original Message----- From: ast...@li... [mailto:ast...@li...]On Behalf Of Jason Wolfe Sent: Saturday, February 04, 2006 1:11 PM To: ast...@li... Subject: RE: [Asterisk-java-users] asterisk manager can't get variable values Thanks for the help, I know I'm close, and just missing something minor. Perhaps I'm not in full understanding of how actions and responses work... I used ethereal to quickly look at the individual packets moving between my client and the asterisk server. I see that asterisk responds to my action with the value that I'm looking for. ManagerResponse actionResponse; GetVarAction getVarAction; getVarAction = new GetVarAction(); getVarAction.setVariable("CONSOLE"); actionResponse = managerConnection.sendAction(getVarAction,10000); System.out.println(actionResponse.toString()); //Why isn't the variable listed in here??? /* this is what I get from actionResponse.toSTring() net.sf.asterisk.manager.response.ManagerResponse: actionId='null'; message='null'; response='Success'; uniqueId='null'; */ String myVar = new String(); myVar = actionResponse.getVariable("CONSOLE"); // System.out.println("myVar=" + myVar); //myVar is null??? Well, if the problem isn't obvious from the code above then I guess I'm heading to the sourcecode to try and pinpoint my misunderstanding. Jason -----Original Message----- From: ast...@li... [mailto:ast...@li...]On Behalf Of María Chóliz Sent: Saturday, February 04, 2006 4:46 AM To: ast...@li... Subject: Re: [Asterisk-java-users] asterisk manager can't get variable values Hi, Jason, I have worked more with the manager_java, not with fastagi, but I think I might try to help you, or I hope so. The code you have just sent does what it should.Visit this page: http://asterisk-java.sourceforge.net/apidocs/net/sf/asterisk/fastagi/command /GetVariableCommand.html see: getVariable() Returns the name of the variable to retrieve. Have you tried witth actions of Manager. If you arer using a version of Asterisk under 1.2...you can set a local variable in the dialplan by using the action SetVarAction, and then getting the value with GetVarAction. Or setting the value in the dialplan and getting it with getvaraction. Getvarction only works with local variables under version 1.2 asterisk , from 1.2 it works also with global variables. I hope this helped you, good luck! |