From e058268edaa505532bee611459b253ec000df841 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Thu, 25 Nov 2010 21:47:12 +0100 Subject: mod_pubsub, util.pubsub: Support for fetching items --- util/pubsub.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'util') 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; -- cgit v1.2.3