Improved group intercept to work with load balanced FusionPBX servers.

This commit is contained in:
Errol Samuels 2014-08-20 21:24:05 +00:00
parent b69cb3182a
commit 93c316dfa6
1 changed files with 24 additions and 3 deletions

View File

@ -16,7 +16,7 @@
--
-- The Initial Developer of the Original Code is
-- Mark J Crane <markjcrane@fusionpbx.com>
-- Copyright (C) 2010 - 2013
-- Copyright (C) 2010 - 2014
-- the Initial Developer. All Rights Reserved.
--
-- Contributor(s):
@ -54,6 +54,13 @@
sounds_dir = session:getVariable("sounds_dir");
context = session:getVariable("context");
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");
@ -156,7 +163,7 @@
assert(dbh:connected());
--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' ";
sql = sql .. "AND (";
x = 0;
@ -181,12 +188,26 @@
-- freeswitch.consoleLog("NOTICE", "row "..key.." "..val.."\n");
--end
uuid = row.uuid;
call_hostname = row.hostname;
ip_addr = row.ip_addr;
end);
end
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