public class GetVarAction extends AbstractManagerAction
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 SetVarAction
through
the Manager API itself.
GetVarAction returns a GetVarResponse
.
To get the actual value from the corresponding
ManagerResponse
call
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
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
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()
.
Constructor and Description |
---|
GetVarAction()
Creates a new empty GetVarAction.
|
GetVarAction(String variable)
Creates a new GetVarAction that queries for the given global variable.
|
GetVarAction(String channel,
String variable)
Creates a new GetVarAction that queries for the given local channel
variable.
|
Modifier and Type | Method and Description |
---|---|
String |
getAction()
Returns the name of this action, i.e.
|
String |
getChannel()
Returns the name of the channel if you query for a local channel variable
or
null if it is a global variable. |
String |
getVariable()
Retruns the name of the variable to query.
|
void |
setChannel(String channel)
Sets the name of the channel if you query for a local channel variable.
|
void |
setVariable(String variable)
Sets the name of the variable to query.
|
getActionId, setActionId, toString
public GetVarAction()
public GetVarAction(String variable)
variable
- the name of the global variable to query.public String getAction()
getAction
in interface ManagerAction
getAction
in class AbstractManagerAction
public String getChannel()
null
if it is a global variable.public void setChannel(String channel)
channel
- the channel if you query for a local channel variable or
null
to query for a gloabl variable.public String getVariable()
public void setVariable(String variable)
Copyright © 2004–2017. All rights reserved.