summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/event/event.lua
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-12 13:53:28 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-12 13:53:28 +0100
commitc9066760fd1f5f2f892ce2be5cf2a83bb5210246 (patch)
tree82ecdd528e803ccd1b469dc13482e06cf8ea0b8e /misc/freeswitch/scripts/event/event.lua
parent0b97717b2171820dea41de8df705f8f0e4b71464 (diff)
parentfb66a5e5a4c5d5f9eac4a5e8de6a286482cb55d5 (diff)
Release a new beta.5.1-beta4
Diffstat (limited to 'misc/freeswitch/scripts/event/event.lua')
-rw-r--r--misc/freeswitch/scripts/event/event.lua33
1 files changed, 25 insertions, 8 deletions
diff --git a/misc/freeswitch/scripts/event/event.lua b/misc/freeswitch/scripts/event/event.lua
index 08d8bfe..652fc48 100644
--- a/misc/freeswitch/scripts/event/event.lua
+++ b/misc/freeswitch/scripts/event/event.lua
@@ -16,29 +16,40 @@ function EventManager.new(self, arg)
self.class = 'eventmanager'
self.database = arg.database;
self.domain = arg.domain;
+ self.consumer = arg.consumer;
return object;
end
function EventManager.register(self)
- self.consumer = freeswitch.EventConsumer('all');
+ if not self.consumer then
+ self.consumer = freeswitch.EventConsumer('all');
+ end
return (self.consumer ~= nil);
end
-function EventManager.load_event_modules(self)
- require 'common.configuration_table'
- self.config = common.configuration_table.get(self.database, 'events');
+function EventManager.load_event_modules(self, modules)
+ local event_modules = {};
+
+ for module_name, index in pairs(modules) do
+ if tonumber(index) and index > 0 then
+ event_modules[index] = module_name;
+ self.log:debug('[event] EVENT_MANAGER - enabled handler module: ', module_name);
+ else
+ self.log:debug('[event] EVENT_MANAGER - disabled handler module: ', module_name);
+ end
+ end
- return self.config.modules;
+ return event_modules;
end
function EventManager.load_event_handlers(self, event_modules)
event_handlers = {}
-
- for event_module_name, index in pairs(event_modules) do
+ for index, event_module_name in ipairs(event_modules) do
+ package.loaded['event.' .. event_module_name] = nil;
event_module = require('event.' .. event_module_name);
if event_module then
self.log:info('[event] EVENT_MANAGER - loading handler module: ', event_module_name);
@@ -71,8 +82,12 @@ end
function EventManager.run(self)
+ require 'common.configuration_table'
+ self.config = common.configuration_table.get(self.database, 'events');
+
+ local event_modules = self:load_event_modules(self.config.modules);
+ self.log:info('[event] EVENT_MANAGER_START - handler modules: ', #event_modules);
- local event_modules = self:load_event_modules();
local event_handlers = self:load_event_handlers(event_modules);
if not event_handlers then
@@ -104,4 +119,6 @@ function EventManager.run(self)
end
end
end
+
+ self.log:info('[event] EVENT_MANAGER_EXIT - action: ', freeswitch.getGlobalVariable('gs_event_manager'));
end