[Freeswitch-users] Loop XML using call_timeout ..

Antonio asilva at wirelessmundi.com
Tue Oct 18 13:29:02 MSD 2011


Yes, a decide to do a lua script for this task.

What I'm doing is a group call that loops all the members until a global
timeout is reached.

Is the code:

call_timeout = session:getVariable("call_timeout") or 60
timestamp_a = os.time()
-- while the call is not answered
while session:answered()==false do
-- dial the group
session:setVariable("call_timeout", call_timeout)
session:execute("bridge","\${group_call(two at default+F)}")

-- bridge state
if (session:ready() == false) then break end
if (session:hangupState()) then break end

-- check global time, and remove the used amount of time already used in
the call
timestamp_b = os.time()
sec = timestamp_b - timestamp_a
timestamp_a = timestamp_b
call_timeout = call_timeout - sec
if (call_timeout <= 0) then
session:setVariable("originate_disposition", "ALLOTTED_TIMEOUT")
debug.info("GROUP: CALL TIMEOUT!")
break
end
end





On Mon, 2011-10-17 at 13:12 -0700, Michael Collins wrote:

> Did you figure this out yet? Not sure exactly what you're trying to do
> here, but you could use the sched_hangup API and schedule a hangup or
> sched_transfer to schedule a transfer to a specific dialplan extension
> that does your cleanup work.
> 
> 
> <action application="set" data="api_res=${sched_transfer +60 ${uuid}
> handle_timeout XML handlers}"/>
> 
> 
> Then something like this for the dp
> 
> 
> <context name="handlers">
>   <extension name="handle loop timeouts">
> 
>     <condition field="destination_number" expression="^handle_timeout
> $">
>       <action application="log" data="INFO OB call timed out..."/>
>       <action application="foo" data="bar"/> <!-- do something useful
> -->
>       <action application="hangup"
> data="pick_a_hangup_cause_if_you_wish"/>
>     </condition>
>   </extensions>
> </context>
> 
> 
> -MC
> 
> On Thu, Oct 13, 2011 at 10:09 AM, Antonio <asilva at wirelessmundi.com>
> wrote:
> 
>         
>         Hi,
>         
>         Is it possible to loop a bridge until a global call timeout
>         (or other variable) is reached?
>         
>         In the wiki is this example is a fixed number of loops...
>         
>         <extension name="3-way gateway distro"> 
>         
>         <condition field="destination_number" expression="^(.*)$">
>               <action application="set" data="continue_on_fail=true"/>
>               <action application="set" data="hangup_after_bridge=true"/>
>               <action application="bridge" data="sofia/gateway/${distributor(3gw)}/$1" loop="3"/>
>             </condition>
>           </extension>
>         
>         My idea is to call a group sequential, but once it reaches the last member it starts over again.
>         so when calling a group, once the timeout for each user in the group is reach it hangups the call (the normal behavior),
>         it jumps again to the begin of the group until a global timeout is reached.
>         
>         For example:
>         
>         <extension name="group"> 
>         <condition field="destination_number" expression="^(.*)$">
>               <action application="set" data="continue_on_fail=true"/>
>               <action application="set" data="hangup_after_bridge=true"/>
>               <action application="set" data="call_timeout=60"/>
>               <action application="set" data="leg_timeout=10"/>
>               <action application="bridge" data=""${group_call(group1 at default+F)}" loop="3"/>
>             </condition>
>           </extension>
>         
>         In my group i have two members only.
>         
>         
>         
>         
>         
>         -- 
>         
>         Un cordial saludo / Best regards, 
>         
>          _________________________
>         
>         António Silva
>         
>         E-mail:asilva at wirelessmundi.com
>         
>         
>         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
>         
> 
> 
> 
> 
> 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


-- 

Un cordial saludo / Best regards, 

 _________________________

António Silva

E-mail:asilva at wirelessmundi.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20111018/93355edd/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list