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 | f3160dd927bc5721635d13262fcacaf3c146dce2 (patch) | |
tree | 9e0fd8d3850c890efbc6006bc361068b64435db2 /util/pubsub.lua | |
parent | e239a678b34730ae83d6a50b59fc48957bf331ea (diff) | |
download | prosody-f3160dd927bc5721635d13262fcacaf3c146dce2.tar.gz prosody-f3160dd927bc5721635d13262fcacaf3c146dce2.zip |
util.pubsub: Support for events (currently subscription-added and subscription-removed)
Diffstat (limited to 'util/pubsub.lua')
-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 |