Jonathan H
2016-Nov-27 17:13 UTC
[asterisk-users] Non-global variable that follows channel?
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()
Richard Mudgett
2016-Nov-27 18:27 UTC
[asterisk-users] Non-global variable that follows channel?
On Sun, Nov 27, 2016 at 11:13 AM, Jonathan H <lardconcepts at gmail.com> wrote:> 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 > :) ) >Have you looked into ARI [1]? I think it would be a closer fit to what you want to do. Richard [1] https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=29395573 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20161127/5bcb3342/attachment.html>
Jonathan H
2016-Nov-27 18:38 UTC
[asterisk-users] Non-global variable that follows channel?
Thanks. I did a while ago, but I couldn't make it "fit" what I wanted to do. Maybe with my increase Asterisk knowledge now I'll take another look. Thanks! On 27 November 2016 at 18:27, Richard Mudgett <rmudgett at digium.com> wrote:> Have you looked into ARI [1]? I think it would be a closer fit to what you > want to do.