Reading global variables is supported since Asterisk 1.2.
You cannot read built-in channel variables such as LANGUAGE
or CALLERIDNUM
using the Manager API. You can only read channel variables that you have explicitly set using the Set
or SetVar
(for Asterisk 1.0.x) applications in the dialplan, in an AGI script or by using the {@link org.asteriskjava.manager.action.SetVarAction} throughthe Manager API itself.
GetVarAction returns a {@link org.asteriskjava.manager.response.GetVarResponse}. To get the actual value from the corresponding {@link org.asteriskjava.manager.response.ManagerResponse} call{@link org.asteriskjava.manager.response.ManagerResponse#getAttribute(String)}with either the variable name as parameter (for Asterisk 1.0.x) or with "Value" as parameter (for Asterisk since 1.2).
Example (for Asterisk 1.2):
GetVarAction getVarAction = new GetVarAction(channel, "MY_VAR"); ManagerResponse response = c.sendAction(getVarAction); String value = response.getAttribute("Value"); System.out.println("MY_VAR on " + channel + " is " + value);Where
c
is an instance of {@link org.asteriskjava.manager.ManagerConnection} and channel
contains the name of a channel instance, for example "SIP/1234-9cd". Since Asterisk-Java 1.0.0 you can also call {@link org.asteriskjava.manager.response.GetVarResponse#getValue()}when using Asterisk 1.2 or later.
Since Asterisk 1.4 this action also supports built-in functions like DB()
, CALLERID()
and ENV()
.
@author srt
@version $Id$
|
|
|
|