login | register
Tue 02 of Dec, 2008 [13:42 UTC]

voip-info.org

History

Asterisk func shared

Created by: JustRumours,Last modification on Wed 06 of Aug, 2008 [09:46 UTC]

Synopsis

Gets or sets the shared variable specified
Introduced with Asterisk 1.6.1

Description


 SHARED(<varname>[,<channel>])

Implements a shared variable area, in which you may share variables between channels. If channel is unspecified, defaults to the current channel. Note that the channel name may be the complete name (i.e. SIP/12-abcd1234) or the prefix only (i.e. SIP/12).

The variables used in this space are separate from the general namespace of the channel and thus ${SHARED(foo)} and ${foo} represent two completely different variables, despite sharing the same name.

Finally, please realize that there is an inherent race between channels operating at the same time, fiddling with each others' internal variables, which is why this special variable namespace exists; it is to remind you that variables in the SHARED namespace may change at any time, without warning. You should therefore take special care to ensure that when using the SHARED namespace, you retrieve the variable and store it in a regular channel variable before using it in a set of calculations (or you might be surprised by the result).

See also



Comments