Mercurial > prosody-hg
comparison plugins/adhoc/mod_adhoc.lua @ 4541:05f5ec99da77
Merge with trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 22 Jan 2012 22:55:49 +0000 |
| parents | 15547fba1f09 |
| children | 58714123f600 |
comparison
equal
deleted
inserted
replaced
| 4530:40905e7bf680 | 4541:05f5ec99da77 |
|---|---|
| 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 |
