Software /
code /
prosody
Diff
core/moduleapi.lua @ 4666:fb522fbd495e
moduleapi: Add module:add_timer(delay, callback) - automatically halts the timer on module unload
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 23 Apr 2012 15:38:40 +0100 |
parent | 4663:24524d70a50a |
child | 4695:838ad61c6b2c |
line wrap: on
line diff
--- a/core/moduleapi.lua Mon Apr 23 15:38:36 2012 +0100 +++ b/core/moduleapi.lua Mon Apr 23 15:38:40 2012 +0100 @@ -316,4 +316,11 @@ 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;