Comparison

util/pubsub.lua @ 3626:444f965baed8

util.pubsub: Add :get_subscription() to return the current subscription for a JID, if any
author Matthew Wild <mwild1@gmail.com>
date Sat, 13 Nov 2010 23:10:50 +0000
parent 3619:291ae816d800
child 3641:3603aeb325de
comparison
equal deleted inserted replaced
3625:f8d61da5bcc1 3626:444f965baed8
19 function service:remove_subscription(node, actor, jid) 19 function service:remove_subscription(node, actor, jid)
20 self.nodes[node].subscribers[jid] = nil; 20 self.nodes[node].subscribers[jid] = nil;
21 return true; 21 return true;
22 end 22 end
23 23
24 function service:get_subscription(node, actor, jid)
25 local node_obj = self.nodes[node];
26 if node_obj then
27 return node_obj.subscribers[jid];
28 end
29 end
30
24 function service:publish(node, actor, id, item) 31 function service:publish(node, actor, id, item)
25 local node_obj = self.nodes[node]; 32 local node_obj = self.nodes[node];
26 if not node_obj then 33 if not node_obj then
27 node_obj = { name = node, subscribers = {}, config = {} }; 34 node_obj = { name = node, subscribers = {}, config = {} };
28 self.nodes[node] = node_obj; 35 self.nodes[node] = node_obj;