aboutsummaryrefslogtreecommitdiffstats
path: root/core/moduleapi.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-05-18 23:53:02 +0100
committerMatthew Wild <mwild1@gmail.com>2012-05-18 23:53:02 +0100
commit0fe909f995ac5f6b26d4eb9bcbc84aa069e33e9e (patch)
tree4b152687bf60b9bb1ea1730f4a09e40a07840d23 /core/moduleapi.lua
parent72ff00a1cd8de2a7a8fea79fea223c85194d4c66 (diff)
downloadprosody-0fe909f995ac5f6b26d4eb9bcbc84aa069e33e9e.tar.gz
prosody-0fe909f995ac5f6b26d4eb9bcbc84aa069e33e9e.zip
moduleapi, modulemanager: Re-structure module.event_handlers so that the same handler can harmlessly handle multiple events (thanks Zash)
Diffstat (limited to 'core/moduleapi.lua')
-rw-r--r--core/moduleapi.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 44c84de1..96f1d3ea 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -70,7 +70,12 @@ function api:fire_event(...)
end
function api:hook_object_event(object, event, handler, priority)
- self.event_handlers[handler] = { name = event, priority = priority, object = object };
+ local handlers = self.event_handlers[event];
+ if not handlers then
+ handlers = {};
+ self.event_handlers[event] = handlers;
+ end
+ handlers[event] = { handler = handler, priority = priority, object = object };
return object.add_handler(event, handler, priority);
end