A little more polish for this feature.

This commit is contained in:
Mark Crane
2015-05-30 04:50:19 +00:00
parent f481386631
commit 629db232ab

View File

@@ -54,10 +54,10 @@
dbh = database_handle('system'); dbh = database_handle('system');
--answer --answer
--session:answer(); session:answer();
--sleep --sleep
--session:sleep(500); session:sleep(500);
--get the domain_uuid --get the domain_uuid
domain_uuid = session:getVariable("domain_uuid"); domain_uuid = session:getVariable("domain_uuid");
@@ -160,7 +160,7 @@
event:addHeader('host', row.server_address); event:addHeader('host', row.server_address);
event:addHeader('content-type', 'application/simple-message-summary'); event:addHeader('content-type', 'application/simple-message-summary');
--check sync --check sync
event:addHeader('event-string', 'check-sync;reboot=true'); event:addHeader('event-string', 'check-sync;reboot=false');
--send the event --send the event
event:fire(); event:fire();
end); end);
@@ -169,14 +169,16 @@
--add the override to the device uuid (login) --add the override to the device uuid (login)
if (authorized == 'true' and action == "login") then if (authorized == 'true' and action == "login") then
if (device_uuid_alternate ~= nil) then if (device_uuid_alternate ~= nil) then
--send a hangup
session:hangup();
--add the new alternate --add the new alternate
sql = [[UPDATE v_devices SET device_uuid_alternate = ']]..device_uuid_alternate..[[']]; sql = [[UPDATE v_devices SET device_uuid_alternate = ']]..device_uuid_alternate..[[']];
sql = sql .. [[WHERE device_uuid = ']]..device_uuid..[[' ]]; sql = sql .. [[WHERE device_uuid = ']]..device_uuid..[[' ]];
sql = sql .. [[AND domain_uuid = ']]..domain_uuid..[[' ]]; sql = sql .. [[AND domain_uuid = ']]..domain_uuid..[[' ]];
if (debug["sql"]) then if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n"); freeswitch.consoleLog("NOTICE", "[provision] sql: ".. sql .. "\n");
end end
dbh:query(sql); dbh:query(sql);
end end
end end
@@ -195,6 +197,8 @@
--found the device send a sync command --found the device send a sync command
if (authorized == 'true') then if (authorized == 'true') then
--send a hangup
session:hangup();
--create the event notify object --create the event notify object
local event = freeswitch.Event('NOTIFY'); local event = freeswitch.Event('NOTIFY');
--add the headers --add the headers
@@ -203,7 +207,7 @@
event:addHeader('host', domain); event:addHeader('host', domain);
event:addHeader('content-type', 'application/simple-message-summary'); event:addHeader('content-type', 'application/simple-message-summary');
--check sync --check sync
event:addHeader('event-string', 'check-sync;reboot=true'); event:addHeader('event-string', 'check-sync;reboot=false');
--send the event --send the event
event:fire(); event:fire();
end end