Hi,

Please see the below script by MC posted a few days earlier. Change the data accordingly. Also see this http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_sched_hangup 

Try setting  the schedule hangup parameter before calling Bridge, I don't think this has any effect while in originate string.


-- test_call
-- create first leg, wait, then connect 2nd leg
--
local calling_user = argv[1];
local called_num = argv[2];

freeswitch.consoleLog("INFO","Attempting to contact user " .. calling_user .. "\n");
local session1 = freeswitch.Session("{origination_caller_id_number=9876}user/"..calling_user);
leg1_dispo = 'None';

while (session1:ready() == true and leg1_dispo ~= 'ANSWER') do
    leg1_dispo = session1:getVariable("endpoint_disposition");
    freeswitch.consoleLog("INFO","Leg 1 disposition:" .. leg1_dispo .. "\n");
    os.execute("sleep 1");
end

if ( not session1:ready() ) then
    -- Oops, leg 1 hung up. Bummer.
    freeswitch.consoleLog("INFO","It appears that " .. calling_user .. " disconnected...\n")
else
    freeswitch.consoleLog("INFO","Playing a prompt to " .. calling_user .. "\n");
    session1:streamFile('ivr/ivr-hold_connect_call.wav');
    session2 = freeswitch.Session("{origination_caller_id_number=" .. calling_user .."}user/" .. called_num);
    leg2_dispo = 'None';
    while(session1:ready() and session2:ready() and leg2_dispo ~= "ANSWER") do
        if ( not session1:ready() ) then
            -- oops, leg 1 hung up
            freeswitch.consoleLog("INFO","Well, it appears that " .. calling_user .. " has disconnected.\n");
        else
            os.execute("sleep 1");
            leg2_dispo = session2:getVariable("endpoint_disposition");
            freeswitch.consoleLog("INFO","Leg 2 disposition: " .. leg2_dispo .. "\n");
        end
    end -- While
    
    if ( session1:ready() and session2:ready() ) then
        -- Looks good, bridge 'em
        freeswitch.bridge(session1,session2);
    else 
        -- Uh oh, someone went away
        freeswitch.consoleLog("INFO","Somebody hung up :(\n");
    end
end

Regards,
Sammy.

On Sun, Dec 25, 2011 at 10:19 PM, Faheem <faheem_imt@yahoo.com> wrote:
Hi all, I am new in this list and this is my first email to this group. 
I need help regarding Bridge application using Lua script.
I want to set the auto hangup for a bridge call in lua script. my script originate leg-A to local extension and then originate leg-b to a carrier and then bridge two legs. I want to hangup the leg-b after some seconds say 20 seconds.
I did the available option, but nothing worked for me. Please help me. 

Here is my lua code.

----------------------------------------------------------------------------------------------------------------
originate_str1 = "{origination_caller_id_number=".. caller.. ",effective_caller_id_number=".. caller ..",originate_timeout=45,ignore_early_media=true}sofia/internal/".. caller .."%" ..domain .."";

originate_str2 = "{origination_caller_id_number=".. callee.. ",effective_caller_id_number=".. callee ..",originate_timeout=60,sched_hangup=20,ignore_early_media=true}sofia/internal/".. carrier_dial_prefix1 .. callee .."%" ..carrier_gateway1 .."";

session1 = freeswitch.Session(originate_str1);
session2 = freeswitch.Session(originate_str2);
freeswitch.bridge(session1, session2);

Thanks! 
Faheem Muhammad






_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org