Realtime extensions: multiple switch statements

I posted this issue at voip-info.org, and inumerous times at #asterisk (freenode), but unfortunately nobody seems to know the answer.

It says at voip-info realtime extensions page that one can have multiple switch statements in a dialplan. But how exactly does it work? Or better, what did the page author mean with that?

I tried to simply stack switch statements one after the other, just as a crash test, like this:

... switch => Realtime/@someextens switch => Realtime/@otherextens ...

The second switch statement will never get loaded. Another interesting thing is when you have mixed dialplans (database and file). Say you call “switch =>” in the flat file (going then to the database one), and at some point in the database dialplan you have a Goto which actually throws execution back to the file (yeah, I know it’s all in memory, I’m just making it simple to understand), that works fine. But the thing is, if you call “switch =>” again in the current context (file), it will never get executed. So once you switched, you can never do it again.

Does anybody know why? Is the wiki page plain and simply wrong? Maybe I got the wrong idea of “having multiple switch statements”, so if anybody could clarify that, it would be most helpful.

Thanks a lot.

[quote=“julioody”]

... switch => Realtime/@someextens switch => Realtime/@otherextens ... [/quote]

Each swtich statement needs to be a part of a context:

[code]
[context_a]

switch => Realtime/context_b@realtimedb

[context_b]

switch => Realtime/context_b@realtimedb[/code]

Where the realtime_db references the database details in your conf file.

Ok, but try going from [context_a] to [context_b] using Goto (in that case, the Goto would have to be in a database, as you probably know). The switch in [context_b] won’t get executed (I mean, I didn’t check to see if it gets executed or not, but in any case, it surely doesn’t make a difference).

That’s the point I was trying to explain. The statements may sit there in your dialplan, but after the first switch, any second one won’t make a difference.

[quote=“julioody”]Ok, but try going from [context_a] to [context_b] using Goto (in that case, the Goto would have to be in a database, as you probably know). The switch in [context_b] won’t get executed (I mean, I didn’t check to see if it gets executed or not, but in any case, it surely doesn’t make a difference).

That’s the point I was trying to explain. The statements may sit there in your dialplan, but after the first switch, any second one won’t make a difference.[/quote]

I use Gotos and GotoIfs in my Realtime extensions setup with no problem, and may go to other contexts with no problem as well. One thing to keep in mind is to use | and not commas, for example:

(in a Realtime database)

exten => s,1,Goto(context_b,s,1) [will not work]

exten => s,1,Goto(context_b|s|1) [works]

I would recommend testing before making an assumption that something does not work.

[i]I use Gotos and GotoIfs in my Realtime extensions setup with no problem, and may go to other contexts with no problem as well. One thing to keep in mind is to use | and not commas, for example:

(in a Realtime database)

exten => s,1,Goto(context_b,s,1) [will not work]

exten => s,1,Goto(context_b|s|1) [works]
[/i]

Good for you. And I can use them too, and probably the entire world. But the question is not about being able to use Goto(If) in realtime extensions and being able to modify your context with it or not. The topic states clearly that the post is about a way to apply multiple switch statements, and more specifically, about a way to call switch more than once (thus, multiple switch statements in the title).

I would recommend testing before making an assumption that something does not work.

And I recommend reading the posts and at least trying to understand them before making an argument for argument’s sake.

ps: asked for it.

What exactly are you trying to do then? Are you saying you want two switch statements in the same context for Realtime extensions? This is not possible and I do not understand what benefit it would provide.

What is possible is having “Multiple Switch Statements in the Dialplan” which I have already explained, and you appear to be aware of and using today.

Now, what you are referring to in the wiki:

[quote=“Asterisk Wiki”]This tells Asterisk that any call into the ‘test’ context are to be switched to RealTime using the context “mycontext” and the family name “realtime_ext”.

context is optional: (switch => Realtime/@realtime_ext) and if left off, RealTime will use the current context, in this case “test”.

family is also optional: (switch => Realtime/@) and if left off, RealTime will use the family name “extensions”.

Currently there are no supported options so you can leave it off.
The family name above can be anything you wish. Just be sure it matches the family name you have stored in extconfig.conf: ( realtime_ext => mysql,asterisk,extensions_table )

And YES! You can have multiple switches and multiple family names using this method. [/quote]

Source

This clearly refers to the family names configured in your /etc/asterisk/extconfig.conf file and the fact that you may have multiple families and switches related to those. Now, when a switch is called the control is passed into the Realtime extensions list and you negate anything thereafter in your extensions.conf dialplan for that context.

Please clarify what you are actually trying to acheive with this approach?