RE: [Asterisk-java-users] asterisk manager can't get variable values
Brought to you by:
srt
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! |