From a1430fb462f9e063338c40464590c496d3cc2562 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 30 Aug 2011 15:03:27 -0400 Subject: util.pubsub: Support for events (currently subscription-added and subscription-removed) --- util/pubsub.lua | 5 +++++ 1 file changed, 5 insertions(+) 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 -- cgit v1.2.3