From 649c7432b75f0faea2e5e7ba7336138f98a8e001 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Sun, 5 Dec 2010 04:19:23 +0100 Subject: mod_pubsub: Support item retraction --- util/pubsub.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'util/pubsub.lua') diff --git a/util/pubsub.lua b/util/pubsub.lua index 4789dff9..02e845e1 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -54,6 +54,18 @@ function service:publish(node, actor, id, item) return true; end +function service:retract(node, actor, id, retract) + local node_obj = self.nodes[node]; + if (not node_obj) or (not node_obj.data[id]) then + return false, "item-not-found"; + end + node_obj.data[id] = nil; + if retract then + self.cb.broadcaster(node, node_obj.subscribers, retract); + end + return true +end + function service:get(node, actor, id) local node_obj = self.nodes[node]; if node_obj then -- cgit v1.2.3