aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-04-23 15:38:40 +0100
committerMatthew Wild <mwild1@gmail.com>2012-04-23 15:38:40 +0100
commitb6a2692f3f90ed40f7e9a5103b1bb141646a7259 (patch)
treee4781caec7ed4eb63a19bfb00175e00b82a0387b
parent91d1035d7d501855d595d80aa985adfac6addfda (diff)
downloadprosody-b6a2692f3f90ed40f7e9a5103b1bb141646a7259.tar.gz
prosody-b6a2692f3f90ed40f7e9a5103b1bb141646a7259.zip
moduleapi: Add module:add_timer(delay, callback) - automatically halts the timer on module unload
-rw-r--r--core/moduleapi.lua7
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;