It’s important to note that when creating another context, the settings and extensions from one context do not propagate to another. Setting up these extensions over and over again can be tedious and will lead to a duplication of code and effort. Thankfully, Asterisk permits other contexts to be joined together via the include => directive.This allows other contexts to be include-ed into the current context and act as one giant context. Let’s go back to our example.The t and i context are duplicated in both the [default] and [supportmenu] contexts.With a couple of small changes, we can make a separate context with just the t and i extensions and include => them into both contexts.
Okay, pop quiz time. Did you notice the difference between this example and the previous one? Don’t
worry if you didn’t, it’s pretty subtle. Because we are including the same t and i context between two files,
the same code will be executed between both. Namely, they will be going to step 1 of the s extension in
both contexts. Previously in the [default] context, the t and i extension went to step 2 of the s extension,
bypassing the Answer() command. What does this change? Not a single thing. Technically, you’re adding an
extra step every time a caller times out or enters an invalid extension, which may affect performance if this
happens repeatedly in a very high-traffic environment, but, in the grand scheme of things this extra step will
not be perceptible. Answer() only answers the call if the call is in an unanswered state. It ignores being
called if the call is already in answered.
Okay, pop quiz time. Did you notice the difference between this example and the previous one? Don’t
worry if you didn’t, it’s pretty subtle. Because we are including the same t and i context between two files,
the same code will be executed between both. Namely, they will be going to step 1 of the s extension in
both contexts. Previously in the [default] context, the t and i extension went to step 2 of the s extension,
bypassing the Answer() command. What does this change? Not a single thing. Technically, you’re adding an
extra step every time a caller times out or enters an invalid extension, which may affect performance if this
happens repeatedly in a very high-traffic environment, but, in the grand scheme of things this extra step will
not be perceptible. Answer() only answers the call if the call is in an unanswered state. It ignores being
called if the call is already in answered.
No comments:
Post a Comment