[Freeswitch-users] B-leg ringing after A-leg hangs-up. LUA.

Тимур Ситдиков sitdikovt at gmail.com
Thu Feb 25 18:44:02 UTC 2021


Hi all. Need help with a simple call script.
I'm got this in dialplan
<extension name="call_lua_home">
      <condition field="destination_number" expression="^(1007)$">
        <!-- <action application="set" data="session_in_hangup_hook=true"/> -->
For hangup hook try
        <action application="lua" data="fork.lua"/>
      </condition>
</extension>
And this in fork.lua
if session:ready() then
api = freeswitch.API()
contact = api:execute("sofia_contact", "*/1007 at compA.com");
caller = session:getVariable("caller_id_number");
session1 = freeswitch.Session("{origination_caller_id_name="..caller..
"}[leg_timeout=30]"..contact.."");
-- session:setHangupHook("HangupHook");
if session1:ready() then
    freeswitch.bridge(session, session1);
end
freeswitch.consoleLog("WARNING","=====SCRIPT END\n");
session:hangup()
end

When Caller is hanging up before B-leg answers - Bleg is continuing to
ring. There are still 2 channels in 'show channels' after A-leg hangs up.
I want to drop B-leg when A-leg hangs up. Is it possible?

UPD Tried to use hangup hook. It works with stramFile, but no luck with
session.
function HangupHook(s, status)
    freeswitch.consoleLog("WARNING","Event fired breaking out\n");
    return exit;
    -- return die;
end

session:answer();
session:setHangupHook("HangupHook");
while (session:ready() == true) do

    session:streamFile(
"/usr/share/freeswitch/sounds/en/us/callie/ivr/16000/ivr-on_hold_indefinitely.wav"
);

-- session1 = freeswitch.Session("{origination_caller_id_name="..caller.."}[leg_timeout=30]"..contact.."");
end
freeswitch.consoleLog("WARNING","=====SCRIPT END\n");
session:hangup()
end

Can anyone help me with this?

Thanks! Regards,Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20210226/870a78d9/attachment.html>


More information about the FreeSWITCH-users mailing list