aboutsummaryrefslogtreecommitdiffstats
path: root/util/pubsub.lua
diff options
context:
space:
mode:
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;