Jonathan H
2016-Nov-23 12:06 UTC
[asterisk-users] Non-global variable that follows channel?
Related to http://lists.digium.com/pipermail/asterisk-users/2016-November/290384.html, at the moment I'm passing one variable via DIAL. Now I'd like to pass a whole bunch, and my idea was to rather than having a great string of b(synctest3b^setVar^1(something)^2(more things)^3(etc)) and then get them with ARG1..ARGn etc, I could bundle the whole lot into a HASH and then unbundle them at the called channel. Passing the HASH as a var isn't working (I wasn't expecting it to!) but is there any other way of doing this, or is it setVar for each one?
Max Grobecker
2016-Nov-27 11:39 UTC
[asterisk-users] Non-global variable that follows channel?
Hi, is channel variable inheritance working for your setup? Passing variables to other channels can normally simply be done by naming the variable with one or two prefixed undersorces to make it available to the channel that is created from that one defining the variable. But I have no idea if it's getting inherited to Gosub called from a Dial command... -> https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_Set If that is not working for you, you might use the SHARED() variables which are kind of global accessible by the channel ID. So you might call your Gosub with only the (unique) reference name of the variables you wish to pass and then call it from your Gosub. -> https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_SHARED Greetings, Max Am 23.11.2016 um 13:06 schrieb Jonathan H:> Related to http://lists.digium.com/pipermail/asterisk-users/2016-November/290384.html, > at the moment I'm passing one variable via DIAL. > > Now I'd like to pass a whole bunch, and my idea was to rather than > having a great string of > > b(synctest3b^setVar^1(something)^2(more things)^3(etc)) > > and then get them with ARG1..ARGn etc, I could bundle the whole lot > into a HASH and then unbundle them at the called channel. > > Passing the HASH as a var isn't working (I wasn't expecting it to!) > but is there any other way of doing this, or is it setVar for each > one? >-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: OpenPGP digital signature URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20161127/b2bc26ee/attachment.pgp>
Jonathan H
2016-Nov-27 14:07 UTC
[asterisk-users] Non-global variable that follows channel?
Thanks, Max. Yes, of course, you are right, and I am an idiot because I was tired and putting underscores before the variable name when I read it back! Then I forgot to post the followup email to say I had figured it out. Now, this SHARED was not something I was aware of, but looked like an ideal solution to passing variables BACK from to the parent channel. However, it does not seem to be very reliable. Code: [svtest1] exten => s,1,Answer() same => n,Verbose(1,Answered channel:${CHANNEL}) same => n,Dial(Local/s at svtest2,,g) same => n,Verbose(1,***In channel:${CHANNEL} sharedVar: ${SHARED(sharedVar,Local/s at svtest2)} ) same => n,Hangup() [svtest2] exten => s,1,NoOp() same => n,Set(SHARED(sharedVar,Local/s at svtest2)="I have been set in svtest2") same => n,Verbose(1,***In channel:${CHANNEL} sharedVar: ${SHARED(sharedVar,Local/s at svtest2)}) same => n,Answer() same => n,Hangup() Output, 4 times from console, 4 times from a normal PJSIP dialin: Of the 8 attempts. in only 3 instances the variable survives the journey back to the parent channel, and seemingly randomly, too. Am I using it incorrectly? CLI> originate local/s at svtest1 application echo Answered channel:Local/s at svtest1-00000027;2 ***In channel:Local/s at svtest2-00000028;2 sharedVar: "I have been set in svtest2" ***In channel:Local/s at svtest1-00000027;2 sharedVar: CLI> originate local/s at svtest1 application echo Answered channel:Local/s at svtest1-00000029;2 ***In channel:Local/s at svtest2-0000002a;2 sharedVar: "I have been set in svtest2" ***In channel:Local/s at svtest1-00000029;2 sharedVar: CLI> originate local/s at svtest1 application echo Answered channel:Local/s at svtest1-0000002b;2 ***In channel:Local/s at svtest2-0000002c;2 sharedVar: "I have been set in svtest2" ***In channel:Local/s at svtest1-0000002b;2 sharedVar: "I have been set in svtest2" CLI> originate local/s at svtest1 application echo Answered channel:Local/s at svtest1-0000002d;2 ***In channel:Local/s at svtest2-0000002e;2 sharedVar: "I have been set in svtest2" ***In channel:Local/s at svtest1-0000002d;2 sharedVar: Answered channel:PJSIP/6001-00000007 ***In channel:Local/s at svtest2-0000002f;2 sharedVar: "I have been set in svtest2" ***In channel:PJSIP/6001-00000007 sharedVar: "I have been set in svtest2" Answered channel:PJSIP/6001-00000008 ***In channel:Local/s at svtest2-00000030;2 sharedVar: "I have been set in svtest2" ***In channel:PJSIP/6001-00000008 sharedVar: Answered channel:PJSIP/6001-00000009 ***In channel:Local/s at svtest2-00000031;2 sharedVar: "I have been set in svtest2" ***In channel:PJSIP/6001-00000009 sharedVar: Answered channel:PJSIP/6001-0000000a ***In channel:Local/s at svtest2-00000032;2 sharedVar: "I have been set in svtest2" ***In channel:PJSIP/6001-0000000a sharedVar: "I have been set in svtest2" On 27 November 2016 at 11:39, Max Grobecker <max.grobecker at ml.grobecker.info> wrote:> Hi, > > is channel variable inheritance working for your setup? > Passing variables to other channels can normally simply be done by naming the variable with one or two prefixed undersorces > to make it available to the channel that is created from that one defining the variable. > But I have no idea if it's getting inherited to Gosub called from a Dial command... > -> https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_Set > > If that is not working for you, you might use the SHARED() variables which are kind of global accessible by the channel ID. > So you might call your Gosub with only the (unique) reference name of the variables you wish to pass and then call it from your Gosub. > -> https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_SHARED > > > Greetings, > Max > > > Am 23.11.2016 um 13:06 schrieb Jonathan H: >> Related to http://lists.digium.com/pipermail/asterisk-users/2016-November/290384.html, >> at the moment I'm passing one variable via DIAL. >> >> Now I'd like to pass a whole bunch, and my idea was to rather than >> having a great string of >> >> b(synctest3b^setVar^1(something)^2(more things)^3(etc)) >> >> and then get them with ARG1..ARGn etc, I could bundle the whole lot >> into a HASH and then unbundle them at the called channel. >> >> Passing the HASH as a var isn't working (I wasn't expecting it to!) >> but is there any other way of doing this, or is it setVar for each >> one? >> > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: https://community.asterisk.org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users
Seemingly Similar Threads
- Non-global variable that follows channel?
- Non-global variable that follows channel?
- [Clang] memory allocation
- Synchronous dialplan execution for feedback while processing speech recognition and voice synth, for example.
- Soft SIP phones that support TLS - Asterisk version 13.13.1