[Freeswitch-users] Need to set and get Global vairables from dialplan

Varsha Agarwal vagarwal at vertical.com
Wed Mar 23 21:12:14 MSK 2016


Thanks for the reply. I changed dialplan as following and still same results

<!--Sample load balancing-->
    <extension name="balance_load">
      <condition field="destination_number" expression="^5050$">
                <action application="set" data="continue_on_fail=true"/>
                <action application="set" data="hangup_after_bridge=true"/>
                <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
                <condition field="${current_node}" expression="^1$">
                                <action="set" data="current_node=2"  inline="true"/>
                                <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
                                <action application="bridge" data="loopback/5000"/>
                </condition>
                <condition field="${current_node}" expression="^2$">
                                <action="set" data="current_node=1"  inline="true"/>
                                <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
                                <action application="bridge" data="sofia/external/5000 at 172.18.19.72"/>
                </condition>
                <action="set" data="current_node=2"  inline="true"/>
                <action application="log" data="INFO *********LOG LEVEL AFTER******** [${current_node}]"/>
                <action application="bridge" data="loopback/5000"/>

      </condition>
    </extension>

Interestingly this is what I see in Freeswitch traces
2016-03-23 11:07:22.895579 [INFO] mod_dptools.c:1692 *********LOG LEVEL******** [1]
2016-03-23 11:07:22.895579 [INFO] mod_dptools.c:1692 *********LOG LEVEL AFTER******** [1]
2016-03-23 11:07:22.895579 [INFO] mod_loopback.c:1075 Sending early media

Even if value for "current_node" is 1 it does not go to <condition field="${current_node}" expression="^1$"> condition. At least it should go there.

From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Ken Rice
Sent: Wednesday, March 23, 2016 6:07 AM
To: 'FreeSWITCH Users Help'
Subject: Re: [Freeswitch-users] Need to set and get Global vairables from dialplan

As with any variables (channel or global) variables are expanded when the dialplan is processed, then a list of actions is built, based on conditions that are met. This is called the Routing Stage in FreeSWITCH Call Processing.
One that Routing Stage is completed, then we move to the Execute Stage where the Actions (or anti-actions) that were added to the list of things to do are executed.

In your example the vars are expanded before the set and log application actions are actually executed.

See https://freeswitch.org/confluence/display/FREESWITCH/XML+Dialplan and look for inline="true" for a more complete explanation on way to do what you are trying.


From: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Varsha Agarwal
Sent: Wednesday, March 23, 2016 12:47 AM
To: FreeSWITCH-users at lists.freeswitch.org<mailto:FreeSWITCH-users at lists.freeswitch.org>
Subject: [Freeswitch-users] Need to set and get Global vairables from dialplan

Hi,

I have created a variable in var.xml, current_node. I am trying to use it in dialplan as below, is this something I can do?

<extension name="balance_load">
      <condition field="destination_number" expression="^5050$">
                <action application="set" data="continue_on_fail=true"/>
                <action application="set" data="hangup_after_bridge=true"/>
                <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
                <condition field="current_node" expression="^1$">
                                <action="set_global" data="current_node=2"/>
                                <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
                                <action application="bridge" data="loopback/5000"/>
                </condition>
                <condition field="current_node" expression="^2$">
                                <action="set_global" data="current_node=2"/>
                                <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
                                <action application="bridge" data="sofia/external/5000 at 172.18.19.72<mailto:sofia/external/5000 at 172.18.19.72>"/>
                </condition>
                <action="set_global" data="current_node=2"/>
                <action application="log" data="INFO *********LOG LEVEL AFTER******** [${current_node}]"/>
                <action application="bridge" data="loopback/5000"/>

      </condition>
    </extension>

Currently log always print current_node = 1 which is the value set in vars.xml.

Thanks,
Varsha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160323/e91f04de/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list