diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-04-23 15:38:40 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-04-23 15:38:40 +0100 |
commit | 78051fedaca3cff787f530aa9cab17d719393a79 (patch) | |
tree | e4781caec7ed4eb63a19bfb00175e00b82a0387b | |
parent | 566fc32a4e01ed5c85f30d09e12bb3a56f7d6081 (diff) | |
download | prosody-78051fedaca3cff787f530aa9cab17d719393a79.tar.gz prosody-78051fedaca3cff787f530aa9cab17d719393a79.zip |
moduleapi: Add module:add_timer(delay, callback) - automatically halts the timer on module unload
-rw-r--r-- | core/moduleapi.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua index e680f615..d16ee410 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -316,4 +316,11 @@ function api:send(stanza) return core_post_stanza(hosts[self.host], stanza); end +function api:add_timer(delay, callback) + return timer.add_task(delay, function (t) + if self.loaded == false then return; end + return callback(t); + end); +end + return api; |