summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/acd_wait.lua
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /misc/freeswitch/scripts/acd_wait.lua
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'misc/freeswitch/scripts/acd_wait.lua')
-rw-r--r--misc/freeswitch/scripts/acd_wait.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/acd_wait.lua b/misc/freeswitch/scripts/acd_wait.lua
new file mode 100644
index 0000000..fd16bea
--- /dev/null
+++ b/misc/freeswitch/scripts/acd_wait.lua
@@ -0,0 +1,45 @@
+-- Gemeinschaft 5: acd call handler
+-- (c) AMOOMA GmbH 2012
+--
+
+local caller_uuid = argv[1];
+local acd_id = tonumber(argv[2]);
+local timeout = tonumber(argv[3]);
+local retry_timeout = tonumber(argv[4]);
+local acd_caller_id = tonumber(argv[5]);
+
+-- initialize logging
+require 'common.log'
+local log = common.log.Log:new{ prefix = '### [' .. caller_uuid .. '] ' };
+
+if not acd_id then
+ log:error('ACD_WAIT - automaticcalldistributor=', acd_id, ' not specified');
+ return;
+end
+
+-- connect to database
+require 'common.database'
+local database = common.database.Database:new{ log = log }:connect();
+if not database:connected() then
+ log:critical('ACD_WAIT - database connect failed');
+ database:release();
+ return;
+end
+
+require 'dialplan.acd'
+local acd = dialplan.acd.AutomaticCallDistributor:new{ log = log, database = database }:find_by_id(acd_id);
+
+if not acd then
+ log:error('ACD_WAIT - automaticcalldistributor=', acd_id, ' not found');
+ database:release();
+ return;
+end
+
+log:debug('ACD_WAIT ', acd_id, ' - start');
+acd:wait_turn(caller_uuid, acd_caller_id, timeout, retry_timeout);
+log:debug('ACD_WAIT ', acd_id, ' - end');
+
+-- release database
+if database then
+ database:release();
+end