[Freeswitch-users] Understanding break="never" in condition-tag

Michael Collins msc at freeswitch.org
Mon Mar 21 23:10:26 MSK 2011


>  I can't/didn't contribute much to this discussion, but I do follow it. My
> idea and (little) testing experience supports the explanation of Dimitry.
> Either way, it 'proofs' there is confusion about the working of the 'break'
> in condition tags.
> If I can find the time, I will try to do some tests / build an example
> myself. Thank you both for the answers and insights so far.
>
>
Okay, for those of you who have the bridge book, please go to page 167-168.
Darren did a really good job of explaining this. For those of you who don't
have the book, SHAME! :)

The break flag determines what happens on processing conditions within a
single extension. Let's say that chan var ${freeswitch} has the value
"rocks" and ${foo} has the value "bar".

<extension name="break_flag_is_not_confusing">
  <condition "${freeswitch}" expression="^lame$">
    <!-- this does not get executed -->
  </condition>
  <!-- the following condition is not even evaluated -->
  <condition "${foo}" expression="bar">
  ...
  </condition>
</extension>

Look at the above snipped. The first condition evaluates to false, which
means all processing for this particular extension stops. The parse "breaks"
out of this extension and moves on to the next one. Now look at this
extension with the the break-flag set to "never"...

<extension name="break_flag_is_not_confusing">
  <condition "${freeswitch}" expression="^lame$" break="never">
    <!-- this does not get executed -->
  </condition>
  <!-- the following condition *is* evaluated -->
  <condition "${foo}" expression="bar">
  ...
  </condition>
</extension>

See the difference? With the break flag set to "never" then it does not
matter whether the condition is evaluated as true or false - the extension's
next condition gets evaluated. Why do you need the break="never"? Simple:
when no "break" is specified there is an implied break="on-false" for the
condition. In other words, by default, if one condition inside of an
extension evaluates to false then all processing for that extension stops.
This has the effect of allowing you to "stack" conditions to create a
logical AND.

So, in summary, the break flag will control how the parser behaves when
evaluating conditions. Normally when a single condition fails, the whole
extension is skipped, however when you do break="never" on a condition then
it does not matter if that particular condition is true or false - extension
processing will continue.

Hope this helps. If it doesn't then read chapters 5 and 8 of the book.
Chapter 5 (me) is a gentle intro into the dialplan. Chapter 8 (Darren) talks
more extensively about the advanced concepts of dialplan processing.

-MC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110321/e3bb076f/attachment-0001.html 


More information about the FreeSWITCH-users mailing list