util.timer API

Prosody provides a system for setting tasks (functions) to run at specified times in the future.

Usage

Reference

timer.add_task(delay, function)

Schedules a function to be called after the specified delay, in seconds.

Note that at the time of writing (Prosody 0.4) timers have an accuracy of +/- 1 second.

Repeating timers

If you want to make a repeating timer then you can simply return a number of seconds until you next want the timer to fire.

For the simplest case, if you "return 60" from your callback then the timer will fire again in another 60 seconds.