Software /
code /
prosody
Changeset
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 |
parents | 4665:6be91ca54613 |
children | 4667:d0cfc49f3f2b |
files | core/moduleapi.lua |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
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;