1 module("pubsub", package.seeall); |
1 module("pubsub", package.seeall); |
2 |
2 |
3 local service = {}; |
3 local service = {}; |
4 local service_mt = { __index = service }; |
4 local service_mt = { __index = service }; |
5 |
5 |
6 function new(cb) |
6 local default_config = { |
7 return setmetatable({ cb = cb or {}, nodes = {} }, service_mt); |
7 broadcaster = function () end; |
|
8 get_affiliation = function () end; |
|
9 capabilities = {}; |
|
10 }; |
|
11 |
|
12 function new(config) |
|
13 config = config or {}; |
|
14 return setmetatable({ |
|
15 config = setmetatable(config, { __index = default_config }); |
|
16 affiliations = {}; |
|
17 nodes = {}; |
|
18 }, service_mt); |
8 end |
19 end |
9 |
20 |
10 function service:add_subscription(node, actor, jid) |
21 function service:add_subscription(node, actor, jid) |
11 local node_obj = self.nodes[node]; |
22 local node_obj = self.nodes[node]; |
12 if not node_obj then |
23 if not node_obj then |