aboutsummaryrefslogtreecommitdiffstats
path: root/util/pubsub.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2010-11-25 21:47:12 +0100
committerFlorian Zeitz <florob@babelmonkeys.de>2010-11-25 21:47:12 +0100
commite058268edaa505532bee611459b253ec000df841 (patch)
tree732bc453b22be4c0ada959fab5b4438ea7cc6f45 /util/pubsub.lua
parent8dd8338afca7afefbb6921a71d399bf1513f3e05 (diff)
downloadprosody-e058268edaa505532bee611459b253ec000df841.tar.gz
prosody-e058268edaa505532bee611459b253ec000df841.zip
mod_pubsub, util.pubsub: Support for fetching items
Diffstat (limited to 'util/pubsub.lua')
-rw-r--r--util/pubsub.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 22a29c18..da90fdcc 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -31,12 +31,23 @@ end
function service:publish(node, actor, id, item)
local node_obj = self.nodes[node];
if not node_obj then
- node_obj = { name = node, subscribers = {}, config = {} };
+ node_obj = { name = node, subscribers = {}, config = {}, data = {} };
self.nodes[node] = node_obj;
end
- node_obj.data = item;
+ node_obj.data[id] = item;
self.cb.broadcaster(node, node_obj.subscribers, item);
return true;
end
+function service:get(node, actor, id)
+ local node_obj = self.nodes[node];
+ if node_obj then
+ if id then
+ return { node_obj.data[id] };
+ else
+ return node_obj.data;
+ end
+ end
+end
+
return _M;