Work on intercept.lua to prevent an error with the hostname.
This commit is contained in:
@@ -45,6 +45,12 @@
|
|||||||
dbh = database_handle('switch');
|
dbh = database_handle('switch');
|
||||||
end
|
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
|
--exits the script if we didn't connect properly
|
||||||
assert(dbh:connected());
|
assert(dbh:connected());
|
||||||
|
|
||||||
@@ -109,6 +115,11 @@ if ( session:ready() ) then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--predefined variables
|
||||||
|
uuid = '';
|
||||||
|
call_hostname = '';
|
||||||
|
callee_num = '';
|
||||||
|
|
||||||
--check the database to get the uuid of a ringing call
|
--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 = "select call_uuid as uuid, hostname, callee_num, ip_addr from channels ";
|
||||||
sql = sql .. "where callstate = 'RINGING' ";
|
sql = sql .. "where callstate = 'RINGING' ";
|
||||||
@@ -129,12 +140,11 @@ if ( session:ready() ) then
|
|||||||
uuid = result.uuid;
|
uuid = result.uuid;
|
||||||
call_hostname = result.hostname;
|
call_hostname = result.hostname;
|
||||||
callee_num = result.callee_num;
|
callee_num = result.callee_num;
|
||||||
ip_addr = result.ip_addr;
|
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the hostname
|
--get the hostname
|
||||||
hostname = freeswitch.getGlobalVariable("hostname");
|
hostname = trim(api:execute("hostname", ""));
|
||||||
freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n");
|
freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n");
|
||||||
|
|
||||||
--intercept a call that is ringing
|
--intercept a call that is ringing
|
||||||
|
|||||||
Reference in New Issue
Block a user