diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-08-30 15:03:27 -0400 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-08-30 15:03:27 -0400 |
commit | a1430fb462f9e063338c40464590c496d3cc2562 (patch) | |
tree | 9e0fd8d3850c890efbc6006bc361068b64435db2 | |
parent | 9cc39d9ff94b830ced6856d8ad1d2383263876fe (diff) | |
download | prosody-a1430fb462f9e063338c40464590c496d3cc2562.tar.gz prosody-a1430fb462f9e063338c40464590c496d3cc2562.zip |
util.pubsub: Support for events (currently subscription-added and subscription-removed)
-rw-r--r-- | util/pubsub.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua index cc606f66..621cf1a6 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -1,3 +1,5 @@ +local events = require "util.events"; + module("pubsub", package.seeall); local service = {}; @@ -16,6 +18,7 @@ function new(config) affiliations = {}; subscriptions = {}; nodes = {}; + events = events.new(); }, service_mt); end @@ -123,6 +126,7 @@ function service:add_subscription(node, actor, jid, options) 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 @@ function service:remove_subscription(node, actor, jid) self.subscriptions[normal_jid] = nil; end end + self.events.fire_event("subscription-removed", { node = node, jid = jid, normalized_jid = normal_jid }); return true; end |