aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-05-04 23:43:01 +0100
committerMatthew Wild <mwild1@gmail.com>2010-05-04 23:43:01 +0100
commit1331d1dbbe855459ece589021a548559d4b27720 (patch)
tree2ba5d4fb08c6ab053125d5d5b613350d556c3856
parentbb00df3f5e95d57c7dff489c5a3da1b292251f85 (diff)
downloadprosody-1331d1dbbe855459ece589021a548559d4b27720.tar.gz
prosody-1331d1dbbe855459ece589021a548559d4b27720.zip
eventmanager, prosody: Adapt eventmanager to use prosody.events, as a step towards removing it entirely
-rw-r--r--core/eventmanager.lua16
-rwxr-xr-xprosody15
2 files changed, 9 insertions, 22 deletions
diff --git a/core/eventmanager.lua b/core/eventmanager.lua
index 0e766c30..1f69c8e1 100644
--- a/core/eventmanager.lua
+++ b/core/eventmanager.lua
@@ -10,24 +10,18 @@
local t_insert = table.insert;
local ipairs = ipairs;
+local events = _G.prosody.events;
+
module "eventmanager"
local event_handlers = {};
function add_event_hook(name, handler)
- if not event_handlers[name] then
- event_handlers[name] = {};
- end
- t_insert(event_handlers[name] , handler);
+ return events.add_handler(name, handler);
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
+ return events.fire_event(name, ...);
end
-return _M; \ No newline at end of file
+return _M;
diff --git a/prosody b/prosody
index a70569b0..8e96eb46 100755
--- a/prosody
+++ b/prosody
@@ -29,6 +29,10 @@ if CFG_DATADIR then
end
end
+-- Global 'prosody' object
+prosody = { events = require "util.events".new(); };
+local prosody = prosody;
+
-- Load the config-parsing module
config = require "core.configmanager"
@@ -148,10 +152,6 @@ function init_global_state()
full_sessions = {};
hosts = {};
- -- Global 'prosody' object
- prosody = {};
- local prosody = prosody;
-
prosody.bare_sessions = bare_sessions;
prosody.full_sessions = full_sessions;
prosody.hosts = hosts;
@@ -161,8 +161,6 @@ function init_global_state()
prosody.arg = _G.arg;
- prosody.events = require "util.events".new();
-
prosody.platform = "unknown";
if os.getenv("WINDIR") then
prosody.platform = "windows";
@@ -193,7 +191,6 @@ function init_global_state()
-- Function to reopen logfiles
function prosody.reopen_logfiles()
log("info", "Re-opening log files");
- eventmanager.fire_event("reopen-log-files"); -- Handled by appropriate log sinks
prosody.events.fire_event("reopen-log-files");
end
@@ -286,7 +283,6 @@ function load_secondary_libraries()
require "util.import"
require "core.xmlhandlers"
require "core.rostermanager"
- require "core.eventmanager"
require "core.hostmanager"
require "core.modulemanager"
require "core.usermanager"
@@ -330,7 +326,6 @@ end
function prepare_to_start()
log("info", "Prosody is using the %s backend for connection handling", server.get_backend());
-- Signal to modules that we are ready to start
- eventmanager.fire_event("server-starting");
prosody.events.fire_event("server-starting");
-- start listening on sockets
@@ -448,14 +443,12 @@ init_data_store();
init_global_protection();
prepare_to_start();
-eventmanager.fire_event("server-started");
prosody.events.fire_event("server-started");
loop();
log("info", "Shutting down...");
cleanup();
-eventmanager.fire_event("server-stopped");
prosody.events.fire_event("server-stopped");
log("info", "Shutdown complete");