Software /
code /
prosody
Diff
util/pubsub.lua @ 3641:3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Thu, 25 Nov 2010 21:47:12 +0100 |
parent | 3626:444f965baed8 |
child | 3672:b24db47995ac |
line wrap: on
line diff
--- a/util/pubsub.lua Fri Nov 26 05:26:12 2010 +0500 +++ b/util/pubsub.lua Thu Nov 25 21:47:12 2010 +0100 @@ -31,12 +31,23 @@ 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;