[Freeswitch-users] Hunting Phase Problem
Michael Collins
msc at freeswitch.org
Wed Nov 9 20:44:33 MSK 2011
Tanin,
Welcome to the FreeSWITCH community! We hope you enjoy your stay. :)
Okay, these are basic but very good questions. If you want a really in
depth discussion I recommend getting the FreeSWITCH book and reviewing
chapters 5 and 8 which discuss dialplan processing in great detail.
However, here is a very brief answer to your question:
There are two basic "phases" to dialplan processing: "hunting" and
"executing". During the hunting phase, the dialplan processor parses the
dialplan looking for extensions with matching conditions. When a condition
matches, any <actions> inside that condition are added to the "task list".
(There are various ways to control this hunting behavior, but let's save
that for a later discussion.)
Once the hunting phase is done, there is a list of actions that needs to be
executed. It's at this point that variables get "expanded". For example
this condition yields a value for $1:
<condition field="destination_number" expression="^(10[01][0-9])$">
$1 will contain whatever is matched in the expression. In this case, it
will be a four-digit number, like "1000", "1001", etc. (For more
information on this topic see http://wiki.freeswitch.org/wiki/Regex)
See this pastebin where I have separated the hunting from the executing:
http://pastebin.freeswitch.org/17732
It's a call to extension 1009. You first see the dialplan hunting starting
at line #3. Notice all the debug lines that begin with "Dialplan:" - these
represent the dialplan parser going over each extension's <condition> tags
looking for matches. You'll see either PASS or FAIL on a match or no match.
(Compare line #76 to line #78.) If there's a match then you'll see any
actions being added to the task list. Look starting at line #79 and you'll
see all the actions being added for this extension. NOTE: if you look in
conf/dialplan/default.xml at the "Local_Extension" dialplan extension
you'll see a direct correspondence to the <action> tags there and the
actions being added here in the log.
Once the dialplan is done hunting it moves on to the execute phase. (See
log entries after line #105.) Notice all the lines beginning with
"EXECUTE:" - these represent the actions on the task list actually being
executed, one at a time and in the order they were added.
That's it! Well, not exactly, but this will get you started. There are a
number of tricks and a few caveats, but you'll get to those in due course.
Feel free to join #freeswitch on irc.freenode.net and chat with us in
realtime. Also, we have a conference call every Wednesday. See the main
wiki page for more information.
-MC
On Wed, Nov 9, 2011 at 6:24 AM, hi tanin <hi_tanin at yahoo.com> wrote:
> I am very new with FreeSwitch. Can anyone tell me:
> What is mean by hunting phase?
> When and how it is use and why and when it is required?
> I want to know details about hunting phase,
>
> Also plese give me a way or tell me when and how the variables($0, $1, $2)
> are used?
>
> Please help me
>
>
>
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20111109/7cf7130b/attachment-0001.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list