comparison plugins/adhoc/mod_adhoc.lua @ 4450:15547fba1f09

mod_adhoc: Use module:handle_items()
author Matthew Wild <mwild1@gmail.com>
date Sat, 10 Dec 2011 05:45:07 +0000
parents 122f142da281
children 58714123f600
comparison
equal deleted inserted replaced
4449:ca74d8ed1a15 4450:15547fba1f09
88 return adhoc_handle_cmd(commands[node], origin, stanza); 88 return adhoc_handle_cmd(commands[node], origin, stanza);
89 end 89 end
90 end 90 end
91 end, 500); 91 end, 500);
92 92
93 local function handle_item_added(item) 93 local function adhoc_added(event)
94 local item = event.item;
94 commands[item.node] = item; 95 commands[item.node] = item;
95 end 96 end
96 97
97 module:hook("item-added/adhoc", function (event) 98 local function adhoc_removed(event)
98 return handle_item_added(event.item); 99 commands[event.item.node] = nil;
99 end, 500); 100 end
100 101
101 module:hook("item-removed/adhoc", function (event) 102 module:handle_items("adhoc", adhoc_added, adhoc_removed);
102 commands[event.item.node] = nil;
103 end, 500);
104
105 -- Pick up any items that are already added
106 for _, item in ipairs(module:get_host_items("adhoc")) do
107 handle_item_added(item);
108 end