aboutsummaryrefslogtreecommitdiffstats
path: root/core/moduleapi.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-01-22 18:49:11 +0000
committerMatthew Wild <mwild1@gmail.com>2012-01-22 18:49:11 +0000
commitf2a5abecac32a7095f1f72e24337e669ba04036c (patch)
tree75289a0c3f4d8ad01ec4bba79bc52fb3d10a388e /core/moduleapi.lua
parent4595904c7580d6ac38f9e659da4c9d9b255526b0 (diff)
downloadprosody-f2a5abecac32a7095f1f72e24337e669ba04036c.tar.gz
prosody-f2a5abecac32a7095f1f72e24337e669ba04036c.zip
modulemanager, moduleapi: Replace hooks multitable with an event_handlers map stored in individual modules. Also adds module:hook_object_event() to hook events on any util.events compatible object.
Diffstat (limited to 'core/moduleapi.lua')
-rw-r--r--core/moduleapi.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index ee960709..3a28ec62 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -66,14 +66,17 @@ function api:fire_event(...)
return (hosts[self.host] or prosody).events.fire_event(...);
end
+function api:hook_object_event(object, event, handler, priority)
+ self.event_handlers[handler] = { name = event, priority = priority, object = object };
+ return object.add_handler(event, handler, priority);
+end
+
function api:hook(event, handler, priority)
- hooks:set(self.host, self.name, event, handler, true);
- (hosts[self.host] or prosody).events.add_handler(event, handler, priority);
+ return self:hook_object_event((hosts[self.host] or prosody).events, event, handler, priority);
end
function api:hook_global(event, handler, priority)
- hooks:set("*", self.name, event, handler, true);
- prosody.events.add_handler(event, handler, priority);
+ return self:hook_object_event(prosody.events, event, handler, priority);
end
function api:hook_stanza(xmlns, name, handler, priority)