Software /
code /
prosody
Changeset
6640:859e9af53aa1
moduleapi: New methods for modules to conveniently wrap events
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 28 Apr 2015 14:18:43 +0100 |
parents | 6639:3003d041c159 |
children | 6641:b44ebfe81c73 |
files | core/moduleapi.lua |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/core/moduleapi.lua Tue Apr 28 13:52:07 2015 +0100 +++ b/core/moduleapi.lua Tue Apr 28 14:18:43 2015 +0100 @@ -120,6 +120,18 @@ return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler); end +function api:wrap_object_event(events_object, event, handler) + return self:hook_object_event(assert(events_object.wrappers, "no wrappers"), event, handler); +end + +function api:wrap_event(event, handler) + return self:wrap_object_event((hosts[self.host] or prosody).events, event, handler); +end + +function api:wrap_global(event, handler) + return self:hook_object_event(prosody.events, event, handler, priority); +end + function api:require(lib) local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment); if not f then