Software /
code /
prosody
Diff
core/modulemanager.lua @ 1319:812c028a877d
modulemanager: Allow setting priority of stanza handlers
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 06 Jun 2009 17:08:47 +0100 |
parent | 1318:66f76c332a75 |
child | 1320:9c736b993e07 |
line wrap: on
line diff
--- a/core/modulemanager.lua Sat Jun 06 16:41:09 2009 +0100 +++ b/core/modulemanager.lua Sat Jun 06 17:08:47 2009 +0100 @@ -368,20 +368,20 @@ return (hosts[self.host] or prosody).events.fire_event(...); end -function api:hook(event, handler) +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); + (hosts[self.host] or prosody).events.add_handler(event, handler, priority); end -function api:hook_stanza(xmlns, name, handler) +function api:hook_stanza(xmlns, name, handler, priority) if not handler and type(name) == "function" then -- If only 2 options then they specified no xmlns - xmlns, name, handler = nil, xmlns, name; + xmlns, name, handler, priority = nil, xmlns, name, handler; elseif not (handler and name and xmlns) then module:log("warn", "Error: Insufficient parameters to module:hook_stanza()"); return; end - return api.hook(self, "stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end); + return api.hook(self, "stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority); end --------------------------------------------------------------------