comparison mod_adhoc/adhoc/mod_adhoc.lua @ 170:0d438a7ac4fc

mod_adhoc: Scan through list of items on load, in case items have been added before we were loaded
author Matthew Wild <mwild1@gmail.com>
date Fri, 11 Jun 2010 15:22:23 +0200
parents b3a68e71b8a1
children 1ae653712e37
comparison
equal deleted inserted replaced
169:b3a68e71b8a1 170:0d438a7ac4fc
57 return adhoc_handle_cmd(commands[node], origin, stanza); 57 return adhoc_handle_cmd(commands[node], origin, stanza);
58 end 58 end
59 end 59 end
60 end, 500); 60 end, 500);
61 61
62 local function handle_item_added(item)
63 commands[item.node] = item;
64 end
65
62 module:hook("item-added/adhoc", function (event) 66 module:hook("item-added/adhoc", function (event)
63 commands[event.item.node] = event.item; 67 return handle_item_added(event.item);
64 end, 500); 68 end, 500);
65 69
66 module:hook("item-removed/adhoc", function (event) 70 module:hook("item-removed/adhoc", function (event)
67 commands[event.item.node] = nil; 71 commands[event.item.node] = nil;
68 end, 500); 72 end, 500);
73
74 -- Pick up any items that are already added
75 for _, item in ipairs(module:get_host_items("adhoc")) do
76 handle_item_added(item);
77 end