summaryrefslogtreecommitdiff
path: root/misc/freeswitch
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-05 15:12:20 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-05 15:12:20 +0100
commit3005e0ecb346db7b3d85d610691dea14be21f5f6 (patch)
tree2f19b96e4d70cfa1b3be703b6dd9025ffd991c2c /misc/freeswitch
parent75b36967fed9db8268391ac10b02f5c0870c32ca (diff)
parente22d3f5cb2791b70a9fcfe6befdeca233772688d (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc/freeswitch')
-rw-r--r--misc/freeswitch/scripts/event/dump_variables.lua52
-rw-r--r--misc/freeswitch/scripts/event/event.lua6
-rw-r--r--misc/freeswitch/scripts/event_manager.lua4
3 files changed, 59 insertions, 3 deletions
diff --git a/misc/freeswitch/scripts/event/dump_variables.lua b/misc/freeswitch/scripts/event/dump_variables.lua
new file mode 100644
index 0000000..96eb8f7
--- /dev/null
+++ b/misc/freeswitch/scripts/event/dump_variables.lua
@@ -0,0 +1,52 @@
+-- Gemeinschaft 5 module: dump_variables event handler class
+-- (c) AMOOMA GmbH 2012-2013
+--
+
+module(...,package.seeall)
+
+
+function handler_class()
+ return DumpVariables
+end
+
+
+DumpVariables = {}
+
+
+function DumpVariables.new(self, arg)
+ arg = arg or {}
+ object = arg.object or {}
+ setmetatable(object, self);
+ self.__index = self;
+ self.log = arg.log;
+ self.class = 'DumpVariables'
+ self.dump_file = arg.file or '/var/log/freeswitch/variables';
+
+ return object;
+end
+
+
+function DumpVariables.event_handlers(self)
+ return { CHANNEL_CREATE = { [true] = self.channel_data } }
+end
+
+
+function DumpVariables.channel_data(self, event)
+ local sequence = event:getHeader('Event-Sequence');
+ local direction = event:getHeader('Call-Direction');
+
+ if not direction or direction ~= 'inbound' then
+ return;
+ end
+
+ local file = io.open(self.dump_file, 'w');
+ if not file then
+ self.log:error('[', event.sequence, '] DUMP_VARIABLES - could not open file for writing: ', self.dump_file);
+ return;
+ end
+
+ self.log:debug('[', event.sequence, '] DUMP_VARIABLES - dumping channel data to: ', self.dump_file);
+
+ file:write(event:serialize(), '\n');
+ file:close();
+end
diff --git a/misc/freeswitch/scripts/event/event.lua b/misc/freeswitch/scripts/event/event.lua
index c98b534..652fc48 100644
--- a/misc/freeswitch/scripts/event/event.lua
+++ b/misc/freeswitch/scripts/event/event.lua
@@ -16,13 +16,16 @@ 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
@@ -117,6 +120,5 @@ function EventManager.run(self)
end
end
- self.consumer = nil;
self.log:info('[event] EVENT_MANAGER_EXIT - action: ', freeswitch.getGlobalVariable('gs_event_manager'));
end
diff --git a/misc/freeswitch/scripts/event_manager.lua b/misc/freeswitch/scripts/event_manager.lua
index 3d558e5..3991f8f 100644
--- a/misc/freeswitch/scripts/event_manager.lua
+++ b/misc/freeswitch/scripts/event_manager.lua
@@ -26,13 +26,15 @@ else
log:error('[event] EVENT_MANAGER_LOADER - No SIP domains found!');
end
+local event_consumer = nil;
freeswitch.setGlobalVariable('gs_event_manager', 'true');
while freeswitch.getGlobalVariable('gs_event_manager') ~= 'false' do
package.loaded['event.event'] = nil;
local manager_class = require('event.event');
- local event_manager = manager_class.EventManager:new{ log = log, database = database, domain = domain }
+ local event_manager = manager_class.EventManager:new{ log = log, database = database, domain = domain, consumer = event_consumer };
freeswitch.setGlobalVariable('gs_event_manager', 'true');
event_manager:run();
+ event_consumer = event_manager.consumer;
end
-- ensure database handle is released on exit