Add conference session logging, add several variables, and ensure the uuids are lower case.
This commit is contained in:
@@ -44,9 +44,132 @@
|
|||||||
dbh = freeswitch.Dbh("core:"..db_path.."/"..db_name);
|
dbh = freeswitch.Dbh("core:"..db_path.."/"..db_name);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--prepare the api object
|
||||||
|
api = freeswitch.API();
|
||||||
|
|
||||||
|
--define the session hangup
|
||||||
|
function session_hangup_hook()
|
||||||
|
|
||||||
|
--get the uuid
|
||||||
|
conference_session_detail_uuid = api:executeString("create_uuid");
|
||||||
|
|
||||||
|
conference_name = session:getVariable("conference_name");
|
||||||
|
conference_session_uuid = session:getVariable("conference_uuid");
|
||||||
|
conference_recording = session:getVariable("conference_recording");
|
||||||
|
conference_moderator = session:getVariable("conference_moderator");
|
||||||
|
--start_epoch = session:getVariable("start_epoch");
|
||||||
|
end_epoch = os.time();
|
||||||
|
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: \n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: domain_uuid: " .. domain_uuid .. "\n");
|
||||||
|
--freeswitch.consoleLog("NOTICE", "Conference Center: domain_name: " .. domain_name .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: meeting_uuid: " .. meeting_uuid .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: conference_name: " .. conference_name .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: conference_uuid: " .. conference_session_uuid .. "\n");
|
||||||
|
if (conference_recording) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: conference_recording: " .. conference_recording .. "\n");
|
||||||
|
end
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: username: " .. username .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: caller_id_name: " .. caller_id_name .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: caller_id_number: " .. caller_id_number .. "\n");
|
||||||
|
--freeswitch.consoleLog("NOTICE", "Conference Center: callee_id_name: " .. callee_id_name .. "\n");
|
||||||
|
--freeswitch.consoleLog("NOTICE", "Conference Center: callee_id_number: " .. callee_id_number .. "\n");
|
||||||
|
--freeswitch.consoleLog("NOTICE", "Conference Center: dialplan: " .. dialplan .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: network_addr: " .. network_addr .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: uuid: " .. uuid .. "\n");
|
||||||
|
--freeswitch.consoleLog("NOTICE", "Conference Center: context: " .. context .. "\n");
|
||||||
|
--freeswitch.consoleLog("NOTICE", "Conference Center: chan_name: " .. chan_name .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: start_epoch: " .. start_epoch .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: end_epoch: " .. end_epoch .. "\n");
|
||||||
|
|
||||||
|
--get the conference sessions
|
||||||
|
sql = [[SELECT count(*) as num_rows
|
||||||
|
FROM v_conference_sessions
|
||||||
|
WHERE conference_session_uuid = ']] .. conference_session_uuid ..[[']];
|
||||||
|
status = dbh:query(sql, function(row)
|
||||||
|
num_rows = string.lower(row["num_rows"]);
|
||||||
|
end);
|
||||||
|
freeswitch.consoleLog("notice", "[conference] SQL: " .. sql .. " Rows:"..num_rows.."\n");
|
||||||
|
if (num_rows == "0") then
|
||||||
|
local sql = {}
|
||||||
|
table.insert(sql, "INSERT INTO v_conference_sessions ");
|
||||||
|
table.insert(sql, "(");
|
||||||
|
table.insert(sql, "conference_session_uuid, ");
|
||||||
|
table.insert(sql, "domain_uuid, ");
|
||||||
|
table.insert(sql, "meeting_uuid, ");
|
||||||
|
if (conference_recording) then
|
||||||
|
table.insert(sql, "recording, ");
|
||||||
|
end
|
||||||
|
--if (wait_mod) then
|
||||||
|
-- table.insert(sql, "wait_mod, ");
|
||||||
|
--end
|
||||||
|
table.insert(sql, "start_epoch, ");
|
||||||
|
table.insert(sql, "end_epoch ");
|
||||||
|
table.insert(sql, ") ");
|
||||||
|
table.insert(sql, "VALUES ");
|
||||||
|
table.insert(sql, "( ");
|
||||||
|
table.insert(sql, "'".. conference_session_uuid .."', ");
|
||||||
|
table.insert(sql, "'".. domain_uuid .."', ");
|
||||||
|
table.insert(sql, "'".. meeting_uuid .."', ");
|
||||||
|
if (conference_recording) then
|
||||||
|
table.insert(sql, "'".. conference_recording .."', ");
|
||||||
|
end
|
||||||
|
--if (wait_mod) then
|
||||||
|
-- table.insert(sql, "'".. wait_mod .."', ");
|
||||||
|
--end
|
||||||
|
table.insert(sql, "'".. start_epoch .."', ");
|
||||||
|
table.insert(sql, "'".. end_epoch .."' ");
|
||||||
|
table.insert(sql, ") ");
|
||||||
|
SQL_STRING = table.concat(sql, "\n");
|
||||||
|
dbh:query(SQL_STRING);
|
||||||
|
freeswitch.consoleLog("notice", "[conference] SQL: " .. SQL_STRING .. "\n");
|
||||||
|
else
|
||||||
|
freeswitch.consoleLog("notice", "[conference] number is greater than 0 \n");
|
||||||
|
end
|
||||||
|
|
||||||
|
local sql = {}
|
||||||
|
table.insert(sql, "INSERT INTO v_conference_session_details ");
|
||||||
|
table.insert(sql, "(");
|
||||||
|
table.insert(sql, "conference_session_detail_uuid, ");
|
||||||
|
table.insert(sql, "domain_uuid, ");
|
||||||
|
table.insert(sql, "conference_session_uuid, ");
|
||||||
|
table.insert(sql, "meeting_uuid, ");
|
||||||
|
table.insert(sql, "username, ");
|
||||||
|
table.insert(sql, "caller_id_name, ");
|
||||||
|
table.insert(sql, "caller_id_number, ");
|
||||||
|
table.insert(sql, "network_addr, ");
|
||||||
|
table.insert(sql, "uuid, ");
|
||||||
|
if (conference_moderator) then
|
||||||
|
table.insert(sql, "moderator, ");
|
||||||
|
end
|
||||||
|
table.insert(sql, "start_epoch, ");
|
||||||
|
table.insert(sql, "end_epoch ");
|
||||||
|
table.insert(sql, ") ");
|
||||||
|
table.insert(sql, "VALUES ");
|
||||||
|
table.insert(sql, "( ");
|
||||||
|
table.insert(sql, "'".. conference_session_detail_uuid .."', ");
|
||||||
|
table.insert(sql, "'".. domain_uuid .."', ");
|
||||||
|
table.insert(sql, "'".. conference_session_uuid .."', ");
|
||||||
|
table.insert(sql, "'".. meeting_uuid .."', ");
|
||||||
|
table.insert(sql, "'".. username .."', ");
|
||||||
|
table.insert(sql, "'".. caller_id_name .."', ");
|
||||||
|
table.insert(sql, "'".. caller_id_number .."', ");
|
||||||
|
table.insert(sql, "'".. network_addr .."', ");
|
||||||
|
table.insert(sql, "'".. uuid .."', ");
|
||||||
|
if (conference_moderator) then
|
||||||
|
table.insert(sql, "'".. conference_moderator .."', ");
|
||||||
|
end
|
||||||
|
table.insert(sql, "'".. start_epoch .."', ");
|
||||||
|
table.insert(sql, "'".. end_epoch .."' ");
|
||||||
|
table.insert(sql, ") ");
|
||||||
|
SQL_STRING = table.concat(sql, "\n");
|
||||||
|
dbh:query(SQL_STRING);
|
||||||
|
end
|
||||||
|
|
||||||
--make sure the session is ready
|
--make sure the session is ready
|
||||||
if ( session:ready() ) then
|
if (session:ready()) then
|
||||||
session:answer( );
|
session:answer();
|
||||||
|
session:setHangupHook("session_hangup_hook");
|
||||||
sounds_dir = session:getVariable("sounds_dir");
|
sounds_dir = session:getVariable("sounds_dir");
|
||||||
domain_name = session:getVariable("domain_name");
|
domain_name = session:getVariable("domain_name");
|
||||||
pin_number = session:getVariable("pin_number");
|
pin_number = session:getVariable("pin_number");
|
||||||
@@ -59,7 +182,7 @@ if ( session:ready() ) then
|
|||||||
freeswitch.consoleLog("notice", "[conference] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[conference] SQL: " .. sql .. "\n");
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(rows)
|
status = dbh:query(sql, function(rows)
|
||||||
domain_uuid = rows["domain_uuid"];
|
domain_uuid = string.lower(rows["domain_uuid"]);
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -72,10 +195,16 @@ if ( session:ready() ) then
|
|||||||
if (not default_voice) then default_voice = 'callie'; end
|
if (not default_voice) then default_voice = 'callie'; end
|
||||||
|
|
||||||
--get the variables
|
--get the variables
|
||||||
domain_name = session:getVariable("domain_name");
|
username = session:getVariable("username");
|
||||||
--meeting_uuid = session:getVariable("meeting_uuid");
|
|
||||||
caller_id_name = session:getVariable("caller_id_name");
|
caller_id_name = session:getVariable("caller_id_name");
|
||||||
caller_id_number = session:getVariable("caller_id_number");
|
caller_id_number = session:getVariable("caller_id_number");
|
||||||
|
callee_id_name = session:getVariable("callee_id_name");
|
||||||
|
callee_id_number = session:getVariable("callee_id_number");
|
||||||
|
dialplan = session:getVariable("dialplan");
|
||||||
|
network_addr = session:getVariable("network_addr");
|
||||||
|
uuid = session:getVariable("uuid");
|
||||||
|
--context = session:getVariable("context");
|
||||||
|
chan_name = session:getVariable("chan_name");
|
||||||
|
|
||||||
--if the pin number is provided then require it
|
--if the pin number is provided then require it
|
||||||
if (not pin_number) then
|
if (not pin_number) then
|
||||||
@@ -83,6 +212,7 @@ if ( session:ready() ) then
|
|||||||
max_digits = 12;
|
max_digits = 12;
|
||||||
pin_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
|
pin_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the conference sessions
|
--get the conference sessions
|
||||||
sql = [[SELECT * FROM v_conference_rooms as s, v_meeting_pins as p
|
sql = [[SELECT * FROM v_conference_rooms as s, v_meeting_pins as p
|
||||||
WHERE s.domain_uuid = ']] .. domain_uuid ..[['
|
WHERE s.domain_uuid = ']] .. domain_uuid ..[['
|
||||||
@@ -93,9 +223,9 @@ if ( session:ready() ) then
|
|||||||
freeswitch.consoleLog("notice", "[conference] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[conference] SQL: " .. sql .. "\n");
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(row)
|
status = dbh:query(sql, function(row)
|
||||||
conference_room_uuid = row["conference_room_uuid"];
|
conference_room_uuid = string.lower(row["conference_room_uuid"]);
|
||||||
conference_center_uuid = row["conference_center_uuid"];
|
conference_center_uuid = string.lower(row["conference_center_uuid"]);
|
||||||
meeting_uuid = row["meeting_uuid"];
|
meeting_uuid = string.lower(row["meeting_uuid"]);
|
||||||
max_members = row["max_members"];
|
max_members = row["max_members"];
|
||||||
wait_mod = row["wait_mod"];
|
wait_mod = row["wait_mod"];
|
||||||
member_type = row["member_type"];
|
member_type = row["member_type"];
|
||||||
@@ -108,6 +238,9 @@ if ( session:ready() ) then
|
|||||||
description = row["description"];
|
description = row["description"];
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
--set the meeting uuid
|
||||||
|
session:setVariable("meeting_uuid", meeting_uuid);
|
||||||
|
|
||||||
if (conference_center_uuid ~= nil) then
|
if (conference_center_uuid ~= nil) then
|
||||||
--set a conference parameter
|
--set a conference parameter
|
||||||
--conference <confname> set <parameter_name> <value>
|
--conference <confname> set <parameter_name> <value>
|
||||||
@@ -121,28 +254,25 @@ if ( session:ready() ) then
|
|||||||
end
|
end
|
||||||
if (enter_sound ~= nil) then
|
if (enter_sound ~= nil) then
|
||||||
session:execute("set","conference_enter_sound="..enter_sound);
|
session:execute("set","conference_enter_sound="..enter_sound);
|
||||||
|
else
|
||||||
|
session:execute("set","conference_enter_sound=");
|
||||||
end
|
end
|
||||||
if (exit_sound ~= nil) then
|
if (exit_sound ~= nil) then
|
||||||
session:execute("set","conference_exit_sound="..exit_sound);
|
session:execute("set","conference_exit_sound="..exit_sound);
|
||||||
end
|
end
|
||||||
|
|
||||||
--working
|
--working
|
||||||
--get number of peoople in the conference
|
--get number of people in the conference
|
||||||
--conference Conference-Center-voip.fusionpbx.com get count
|
--conference Conference-Center-voip.fusionpbx.com get count
|
||||||
--get number of seconds since the conference started
|
--get number of seconds since the conference started
|
||||||
--conference Conference-Center-voip.fusionpbx.com get run_time
|
--conference Conference-Center-voip.fusionpbx.com get run_time
|
||||||
--get max members in a conference
|
if (wait_mod == "true") then
|
||||||
--conference Conference-Center-voip.fusionpbx.com get max_members
|
|
||||||
--conference Conference-Center-voip.fusionpbx.com set max_members 3
|
|
||||||
--sound
|
|
||||||
--session:execute("set","conference_enter_sound="..enter_sound);
|
|
||||||
--session:execute("set","conference_exit_sound="..exit_sound);
|
|
||||||
--used when the first member joins the conference
|
|
||||||
--session:execute("set","conference_max_members="..max_members);
|
|
||||||
--if (wait_mod == "true") then
|
|
||||||
--flags = flags .. "|wait_mod"; --not working
|
--flags = flags .. "|wait_mod"; --not working
|
||||||
--session:execute("conference","Conference-Center-voip.fusionpbx.com(set conference-flags=wait-mod)"); --not working
|
--session:execute("conference","Conference-Center-voip.fusionpbx.com(set conference-flags=wait-mod)"); --not working
|
||||||
--end
|
conference_profile = "wideband-wait-mod";
|
||||||
|
else
|
||||||
|
conference_profile = "default";
|
||||||
|
end
|
||||||
if (member_type == "moderator") then
|
if (member_type == "moderator") then
|
||||||
--set as the moderator
|
--set as the moderator
|
||||||
flags = flags .. "|moderator";
|
flags = flags .. "|moderator";
|
||||||
@@ -152,14 +282,27 @@ if ( session:ready() ) then
|
|||||||
session:execute("set","conference_controls=moderator");
|
session:execute("set","conference_controls=moderator");
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--set the start epoch
|
||||||
|
start_epoch = os.time();
|
||||||
|
|
||||||
--send the call to the conference
|
--send the call to the conference
|
||||||
--session:execute("conference","confname@profilename+[conference pin number]+flags{moderator}");
|
--session:execute("conference","confname@profilename+[conference pin number]+flags{moderator}");
|
||||||
cmd = meeting_uuid.."-"..domain_name.."@default+flags{".. flags .."}";
|
cmd = meeting_uuid.."-"..domain_name.."@"..conference_profile.."+flags{".. flags .."}";
|
||||||
freeswitch.consoleLog("notice", "[conference] ".. cmd .."\n");
|
freeswitch.consoleLog("notice", "[conference] ".. cmd .."\n");
|
||||||
session:execute("conference",cmd);
|
session:execute("conference",cmd);
|
||||||
--alternative
|
--alternative
|
||||||
--uuid_transfer <uuid> conference:3000@default inline
|
--uuid_transfer <uuid> conference:3000@default inline
|
||||||
|
|
||||||
|
--get the conference variables
|
||||||
|
conference_name = session:getVariable("conference_name");
|
||||||
|
conference_uuid = session:getVariable("conference_uuid");
|
||||||
|
conference_recording = session:getVariable("conference_recording");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: conference_name: 2 " .. conference_name .. "\n");
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: conference_uuid: 2 " .. conference_uuid .. "\n");
|
||||||
|
if (conference_recording) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "Conference Center: conference_recording: " .. conference_recording .. "\n");
|
||||||
|
end
|
||||||
|
|
||||||
--freeswitch.consoleLog("notice", "[conference] line: 147\n");
|
--freeswitch.consoleLog("notice", "[conference] line: 147\n");
|
||||||
else
|
else
|
||||||
session:streamFile("phrase:voicemail_fail_auth:#");
|
session:streamFile("phrase:voicemail_fail_auth:#");
|
||||||
|
|||||||
Reference in New Issue
Block a user