net.http.server: Properly handle persistent connections
[prosody.git] / plugins / adhoc / mod_adhoc.lua
index 6d8263386493311221c3820e19106b67b56afdd3..69b2c8da9903e101afce81f053f4d00d7a0197d6 100644 (file)
@@ -90,19 +90,14 @@ module:hook("iq/host/"..xmlns_cmd..":command", function (event)
        end
 end, 500);
 
-local function handle_item_added(item)
+local function adhoc_added(event)
+       local item = event.item;
        commands[item.node] = item;
 end
 
-module:hook("item-added/adhoc", function (event)
-       return handle_item_added(event.item);
-end, 500);
-
-module:hook("item-removed/adhoc", function (event)
+local function adhoc_removed(event)
        commands[event.item.node] = nil;
-end, 500);
-
--- Pick up any items that are already added
-for _, item in ipairs(module:get_host_items("adhoc")) do
-       handle_item_added(item);
 end
+
+module:handle_items("adhoc", adhoc_added, adhoc_removed);
+module:handle_items("adhoc-provider", adhoc_added, adhoc_removed);