FreeSWITCH 1.8
上QQ阅读APP看书,第一时间看更新

"Normal" Variables

Most FreeSWITCH variables are indicated by the syntax ${varname}. Variables can be created, assigned and re-assigned. Actually, assigning a value to a variable creates it, if it does not already exists. If it exists, it reassign it to the new value.

<action application="set" data="mystring='Rehan Allahwala'"/>

<action application="set" data="mystring2=SuzanneBowen"/>

<action application="set" data="mystring2=${mystring}"/>

The application "set" assign variables. Here we see how it works in dialplan "actions".
When we create or reassign a variable, we use its name (without the ${} syntax). Inside the "data" argument of the "set" action, we use the equal sign (=) to separate the variable name from its (new) value. The single quotes are used to enclose a value when it contains spaces.

When we want to use the variable's value, we use the dollar syntax.
So, in previous example, we first assigned a value to the variable named "mystring" (creating it if it does not exists). Then we assign a value to the "mystring2" variable. In the last line we reassign "mystring2" variable, giving it the value contained into the "mystring" variable. The value of ${mystring2} is now 'Rehan Allahwala'.

All variables can be used by all modules and parts of FreeSWITCH. What does it means? That, for example, when a user that is member of the "sales" group originates a call, you can set a variable on that call. You can then have one of the Call Detail Record modules to track that variable, putting it in CDRs and allowing your company to identify cost centers.

Variables can be created by us out of nothing, or they can be automatically created by FreeSWITCH, from information inherent the calls, the environment, the time of day, etc.

Some variables reflect values from the various configuration files. Most of the variables from configuration files are "writable". For example, we can set a default value for our Station Identifier (that is, assign our own company name) when sending faxes, and then we can override it reassigning it to "ACME co" in dialplan when we use our same FreeSWITCH server as send fax service for a customer.