From a6c6e8b945fe536e9953bc14cbb94f4c8dfee9f9 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 22 Aug 2014 07:57:47 +0000 Subject: [PATCH] Align intercept with group interceptl --- resources/install/scripts/intercept.lua | 22 ++++++++++++++++--- resources/install/scripts/intercept_group.lua | 8 +------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index a6dc7aa99a..e659f868b0 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -16,7 +16,7 @@ -- -- The Initial Developer of the Original Code is -- Mark J Crane --- Copyright (C) 2010 +-- Copyright (C) 2010 - 2014 -- the Initial Developer. All Rights Reserved. -- -- Contributor(s): @@ -56,6 +56,7 @@ if ( session:ready() ) then sounds_dir = session:getVariable("sounds_dir"); domain_name = session:getVariable("domain_name"); context = session:getVariable("context"); + sofia_profile_name = session:getVariable("sofia_profile_name"); --set the sounds path for the language, dialect and voice default_language = session:getVariable("default_language"); @@ -107,7 +108,7 @@ if ( session:ready() ) then end --check the database to get the uuid of a ringing call - sql = "select call_uuid as uuid from channels "; + sql = "select call_uuid as uuid, hostname, ip_addr from channels "; sql = sql .. "where callstate = 'RINGING' "; if (extension) then sql = sql .. "and presence_id = '"..extension.."@"..domain_name.."' "; @@ -124,13 +125,28 @@ if ( session:ready() ) then -- freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n"); --end uuid = result.uuid; + call_hostname = result.hostname; + ip_addr = result.ip_addr; end); end +--get the hostname + hostname = freeswitch.getGlobalVariable("hostname"); + freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n"); + --intercept a call that is ringing if (uuid) then - session:execute("intercept", uuid); + if (hostname == call_hostname) then + session:execute("intercept", uuid); + else + session:execute("export", "sip_h_X-intercept_uuid="..uuid); + session:execute("export", "sip_h_X-domain_uuid="..domain_uuid); + session:execute("export", "sip_h_X-domain_name="..domain_name); + port = freeswitch.getGlobalVariable(sofia_profile_name.."_sip_port"); + session:execute("bridge", "sofia/"..sofia_profile_name.."/*8@"..call_hostname..":"..port); + freeswitch.consoleLog("NOTICE", "Send call to other host.... \n"); + end end --notes diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index b282e69e35..50bb8cd361 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -56,12 +56,6 @@ caller_id_number = session:getVariable("caller_id_number"); sofia_profile_name = session:getVariable("sofia_profile_name"); - if (domain_count > 1) then - if (context == "public") then - context = domain_name; - end - end - --set the sounds path for the language, dialect and voice default_language = session:getVariable("default_language"); default_dialect = session:getVariable("default_dialect"); @@ -193,6 +187,7 @@ end); end +--get the hostname hostname = freeswitch.getGlobalVariable("hostname"); freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n"); @@ -215,4 +210,3 @@ --cmd = "originate user/1007@voip.example.com &intercept("..uuid..")"; --api = freeswitch.API(); --result = api:executeString(cmd); -