Diff

core/modulemanager.lua @ 569:5216efe6088b

Add hostmanager, and eventmanager
author Matthew Wild <mwild1@gmail.com>
date Sat, 06 Dec 2008 03:41:49 +0000
parent 540:ec03f6968fa8
child 573:f6555ebf84ec
line wrap: on
line diff
--- a/core/modulemanager.lua	Sat Dec 06 03:40:51 2008 +0000
+++ b/core/modulemanager.lua	Sat Dec 06 03:41:49 2008 +0000
@@ -24,6 +24,8 @@
 local logger = require "util.logger";
 local log = logger.init("modulemanager");
 local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler;
+local eventmanager = require "core.eventmanager";
+
 
 local loadfile, pcall = loadfile, pcall;
 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv;
@@ -182,28 +184,7 @@
 	end);
 end
 
-
-do
-	local event_handlers = {};
-	
-	function api:add_event_hook(name, handler)
-		if not event_handlers[name] then
-			event_handlers[name] = {};
-		end
-		t_insert(event_handlers[name] , handler);
-		self:log("debug", "Subscribed to %s", name);
-	end
-	
-	function fire_event(name, ...)
-		local event_handlers = event_handlers[name];
-		if event_handlers then
-			for name, handler in ipairs(event_handlers) do
-				handler(...);
-			end
-		end
-	end
-end
-
+api.add_event_hook = eventmanager.add_event_hook;
 
 local function _add_handler(module, origin_type, tag, xmlns, handler)
 	local handlers = stanza_handlers[module.host];