Software /
code /
prosody
Changeset
4365:6704b3cd032e
util.pubsub: Support for events (currently subscription-added and subscription-removed)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 30 Aug 2011 15:03:27 -0400 |
parents | 4364:af40cf682eba |
children | 4366:b6c18cadd3ec |
files | util/pubsub.lua |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/pubsub.lua Mon Aug 29 15:42:15 2011 -0400 +++ b/util/pubsub.lua Tue Aug 30 15:03:27 2011 -0400 @@ -1,3 +1,5 @@ +local events = require "util.events"; + module("pubsub", package.seeall); local service = {}; @@ -16,6 +18,7 @@ affiliations = {}; subscriptions = {}; nodes = {}; + events = events.new(); }, service_mt); end @@ -123,6 +126,7 @@ else self.subscriptions[normal_jid] = { [jid] = { [node] = true } }; end + self.events.fire_event("subscription-added", { node = node, jid = jid, normalized_jid = normal_jid, options = options }); return true; end @@ -163,6 +167,7 @@ self.subscriptions[normal_jid] = nil; end end + self.events.fire_event("subscription-removed", { node = node, jid = jid, normalized_jid = normal_jid }); return true; end