Mercurial > prosody-hg
comparison plugins/adhoc/mod_adhoc.lua @ 3231:ad3fbed1dda5
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 13:23:10 +0100 |
| parents | b3772f9bc359 |
| children | e5234625fc42 |
comparison
equal
deleted
inserted
replaced
| 3230:a5c3a82d677e | 3231:ad3fbed1dda5 |
|---|---|
| 56 return adhoc_handle_cmd(commands[node], origin, stanza); | 56 return adhoc_handle_cmd(commands[node], origin, stanza); |
| 57 end | 57 end |
| 58 end | 58 end |
| 59 end, 500); | 59 end, 500); |
| 60 | 60 |
| 61 local function handle_item_added(item) | |
| 62 commands[item.node] = item; | |
| 63 end | |
| 64 | |
| 61 module:hook("item-added/adhoc", function (event) | 65 module:hook("item-added/adhoc", function (event) |
| 62 commands[event.item.node] = event.item; | 66 return handle_item_added(event.item); |
| 63 end, 500); | 67 end, 500); |
| 64 | 68 |
| 65 module:hook("item-removed/adhoc", function (event) | 69 module:hook("item-removed/adhoc", function (event) |
| 66 commands[event.item.node] = nil; | 70 commands[event.item.node] = nil; |
| 67 end, 500); | 71 end, 500); |
| 72 | |
| 73 -- Pick up any items that are already added | |
| 74 for _, item in ipairs(module:get_host_items("adhoc")) do | |
| 75 handle_item_added(item); | |
| 76 end |
