From b6a2692f3f90ed40f7e9a5103b1bb141646a7259 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 23 Apr 2012 15:38:40 +0100 Subject: moduleapi: Add module:add_timer(delay, callback) - automatically halts the timer on module unload --- core/moduleapi.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core') 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; -- cgit v1.2.3