[asterisk-users] Non-global variable that follows channel?
Jonathan H
lardconcepts at gmail.com
Sun Nov 27 11:13:23 CST 2016
Thanks, Richard - your code does indeed work reliably 100% of the
time, and thank you for that explanation.
I do think the docs at
https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_SHARED
could do with more clarification.
BTW, there were a couple of typos in your code, so for anyone who
wants to copy/paste, here's Richard's code WITH the curly braces (
Set(SHARED(sharedVar,MY_CALLER) should be
Set(SHARED(sharedVar,${MY_CALLER}) )
[svtest1]
exten => s,1,Answer()
same => n,Verbose(1,Answered channel:${CHANNEL})
same => n,Set(__MY_CALLER=${CHANNEL(name)})
same => n,Dial(Local/s at svtest2,,g)
same => n,Verbose(1,***In channel:${CHANNEL} sharedVar:${SHARED(sharedVar)})
same => n,Hangup()
[svtest2]
exten => s,1,NoOp()
same => n,Set(SHARED(sharedVar,${MY_CALLER})="I have been set in
svtest2 by ${CHANNEL(name)}")
same => n,Verbose(1,***In channel:${CHANNEL} sharedVar:
${SHARED(sharedVar,Local/s at svtest2)})
same => n,Answer()
same => n,Hangup()
Thanks again.
(BTW, looking forward to the day when Asterisk gets some kind of
asynchronous dialplan application - all this "dialling a local
channel" is just to get via music on hold so there's not silence while
a long operation happening, as per
http://lists.digium.com/pipermail/asterisk-users/2016-November/290384.html
:) )
On 27 November 2016 at 16:16, Richard Mudgett <rmudgett at digium.com> wrote:
> [svtest1]
> exten = s,1,NoOp()
> same = n,Answer()
> same = n,Set(__MY_CALLER=${CHANNEL(name)})
> same = n,Dial(Local/s at svtest2,,g)
> same = n,NoOp(Returned SHARED(sharedVar) = '${SHARED(sharedVar)'}
> same = n,Hangup()
>
> [svtest2]
> exten = s,1,NoOp()
> exten = n,Set(SHARED(sharedVar,MY_CALLER)="I have been set in svtest2 by
> ${CHANNEL(name)}")
> exten = n,Answer()
> exten = n,Hangup()
More information about the asterisk-users
mailing list