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

Anthony Minessale anthony.minessale at gmail.com
Mon Mar 21 23:44:50 MSK 2011


The simple way to put it is that in the example in this email that is
from the wiki, using an empty condition with break=never is a noOP.

The typical usage of break=never would be if you wanted to execute
some extra options when a condition was true and skip it but keep
going when its not true.


<extension>
  <!-- because break=never even when the destionation does not begin
with 1 we just don't execute these actions and keep going -->
  <condition field="destination_number" expression="^1(\d+)$" break="never">
    <action application="set" data="begins_with_one=true"/>
  </condition>

  <condition field="destination_number" expression="^(\d+)$">
    <action application="bridge" data="sofia/internal/$1 at foobar.com"/>
  </condition>

</extension>

So stacking conditions with no actions in them and putting break=never
on them is the same as if they do not exist.




On Mon, Mar 21, 2011 at 3:10 PM, Michael Collins <msc at freeswitch.org> wrote:
>
>>
>> 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
>
> _______________________________________________
> 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
>
>



-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale at hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org
googletalk:conf+888 at conference.freeswitch.org
pstn:+19193869900



More information about the FreeSWITCH-users mailing list