Schedule callbacks to be called in the future.
More...
|
unsigned | discord_timer_ctl (struct discord *client, struct discord_timer *timer) |
| modifies or creates a timer More...
|
|
unsigned | discord_timer (struct discord *client, discord_ev_timer on_tick_cb, discord_ev_timer on_status_changed_cb, void *data, int64_t delay) |
| creates a one shot timer that automatically deletes itself upon completion More...
|
|
unsigned | discord_timer_interval (struct discord *client, discord_ev_timer on_tick_cb, discord_ev_timer on_status_changed_cb, void *data, int64_t delay, int64_t interval, int64_t repeat) |
| creates a repeating timer that automatically deletes itself upon completion More...
|
|
bool | discord_timer_get (struct discord *client, unsigned id, struct discord_timer *timer) |
| get the data associated with the timer More...
|
|
bool | discord_timer_start (struct discord *client, unsigned id) |
| starts a timer More...
|
|
bool | discord_timer_stop (struct discord *client, unsigned id) |
| stops a timer More...
|
|
bool | discord_timer_cancel (struct discord *client, unsigned id) |
| cancels a timer, this will delete the timer if DISCORD_TIMER_DELETE_AUTO is enabled More...
|
|
bool | discord_timer_delete (struct discord *client, unsigned id) |
| deletes a timer More...
|
|
bool | discord_timer_cancel_and_delete (struct discord *client, unsigned id) |
| cancels, and deletes a timer More...
|
|
Schedule callbacks to be called in the future.
◆ discord_ev_timer
◆ discord_timer_flags
flags used to change behaviour of timer
Enumerator |
---|
DISCORD_TIMER_MILLISECONDS | use milliseconds for interval and start_time
|
DISCORD_TIMER_MICROSECONDS | use microseconds for interval and start_time
|
DISCORD_TIMER_DELETE | whether or not timer is marked for deletion
|
DISCORD_TIMER_DELETE_AUTO | automatically delete a timer once its repeat counter runs out
|
DISCORD_TIMER_CANCELED | timer has been canceled. user should cleanup only
|
DISCORD_TIMER_TICK | flag is set when on_tick callback has been called
|
DISCORD_TIMER_GET | used in discord_timer_ctl to get the timer's data
|
DISCORD_TIMER_INTERVAL_FIXED | timer should run using a fixed interval based on start time
|
◆ discord_timer_ctl()
modifies or creates a timer
- Parameters
-
client | the client created with discord_init() |
timer | the timer that should be modified |
- Returns
- the id of the timer
◆ discord_timer()
creates a one shot timer that automatically deletes itself upon completion
- Parameters
-
client | the client created with discord_init() |
on_tick_cb | (nullable) the callback that should be called when timer triggers |
on_status_changed_cb | (nullable) the callback for status updates timer->flags will have: DISCORD_TIMER_CANCELED, and DISCORD_TIMER_DELETE |
data | user data |
delay | delay before timer should start in milliseconds |
- Returns
- the id of the timer
- Examples
- timers.c.
◆ discord_timer_interval()
creates a repeating timer that automatically deletes itself upon completion
- Parameters
-
client | the client created with discord_init() |
on_tick_cb | (nullable) the callback that should be called when timer triggers |
on_status_changed_cb | (nullable) the callback for status updates timer->flags will have: DISCORD_TIMER_CANCELED, and DISCORD_TIMER_DELETE |
data | user data |
delay | delay before timer should start in milliseconds |
interval | interval between runs. (-1 == disable repeat) |
repeat | repetitions (-1 == infinity) |
- Returns
- the id of the timer
- Examples
- timers.c.
◆ discord_timer_get()
get the data associated with the timer
- Parameters
-
client | the client created with discord_init() |
id | id of the timer |
timer | where to copy the timer data to |
- Returns
- true on success
◆ discord_timer_start()
bool discord_timer_start |
( |
struct discord * |
client, |
|
|
unsigned |
id |
|
) |
| |
starts a timer
- Parameters
-
- Returns
- true on success
◆ discord_timer_stop()
bool discord_timer_stop |
( |
struct discord * |
client, |
|
|
unsigned |
id |
|
) |
| |
stops a timer
- Parameters
-
- Returns
- true on success
◆ discord_timer_cancel()
bool discord_timer_cancel |
( |
struct discord * |
client, |
|
|
unsigned |
id |
|
) |
| |
cancels a timer, this will delete the timer if DISCORD_TIMER_DELETE_AUTO is enabled
- Parameters
-
- Returns
- true on success
- Examples
- timers.c.
◆ discord_timer_delete()
bool discord_timer_delete |
( |
struct discord * |
client, |
|
|
unsigned |
id |
|
) |
| |
deletes a timer
- Parameters
-
- Returns
- true on success
◆ discord_timer_cancel_and_delete()
bool discord_timer_cancel_and_delete |
( |
struct discord * |
client, |
|
|
unsigned |
id |
|
) |
| |
cancels, and deletes a timer
- Parameters
-
- Returns
- true on success