Work on intercept.lua to prevent an error with the hostname.

This commit is contained in:
Mark Crane
2015-01-30 01:32:38 +00:00
parent f012c75eb6
commit 70032d5642

View File

@@ -45,6 +45,12 @@
dbh = database_handle('switch');
end
--prepare the api object
api = freeswitch.API();
--add the function
dofile(scripts_dir.."/resources/functions/trim.lua");
--exits the script if we didn't connect properly
assert(dbh:connected());
@@ -109,6 +115,11 @@ if ( session:ready() ) then
end
end
--predefined variables
uuid = '';
call_hostname = '';
callee_num = '';
--check the database to get the uuid of a ringing call
sql = "select call_uuid as uuid, hostname, callee_num, ip_addr from channels ";
sql = sql .. "where callstate = 'RINGING' ";
@@ -129,12 +140,11 @@ if ( session:ready() ) then
uuid = result.uuid;
call_hostname = result.hostname;
callee_num = result.callee_num;
ip_addr = result.ip_addr;
end);
end
--get the hostname
hostname = freeswitch.getGlobalVariable("hostname");
hostname = trim(api:execute("hostname", ""));
freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n");
--intercept a call that is ringing