util/pubsub.lua

changeset 3822
d6028f4eb610
parent 3821
cef2d5dc65e3
child 3759
1f7305784e12
equal deleted inserted replaced
3821:cef2d5dc65e3 3822:d6028f4eb610
52 node_obj.data[id] = item; 52 node_obj.data[id] = item;
53 self.cb.broadcaster(node, node_obj.subscribers, item); 53 self.cb.broadcaster(node, node_obj.subscribers, item);
54 return true; 54 return true;
55 end 55 end
56 56
57 function service:retract(node, actor, id, retract)
58 local node_obj = self.nodes[node];
59 if (not node_obj) or (not node_obj.data[id]) then
60 return false, "item-not-found";
61 end
62 node_obj.data[id] = nil;
63 if retract then
64 self.cb.broadcaster(node, node_obj.subscribers, retract);
65 end
66 return true
67 end
68
57 function service:get(node, actor, id) 69 function service:get(node, actor, id)
58 local node_obj = self.nodes[node]; 70 local node_obj = self.nodes[node];
59 if node_obj then 71 if node_obj then
60 if id then 72 if id then
61 return { node_obj.data[id] }; 73 return { node_obj.data[id] };

mercurial