#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
static void
{
printf("Timer '%s' id:%u flags:%i "
"delay:%" PRIi64 " interval:%" PRIi64 " repeat:%" PRIi64 "\n",
}
static void
{
print_timer_info(timer, "on_timer_tick");
puts("Canceling repeating timer.");
}
}
static void
{
print_timer_info(timer, "on_timer_status_changed");
puts("TIMER CANCELED");
}
puts("TIMER DELETED - FREEING DATA");
}
}
static void
{
print_timer_info(timer, "use_same_function");
puts("TIMER TICK");
}
puts("TIMER CANCELED");
}
puts("TIMER DELETED - FREEING DATA");
}
}
int
main(int argc, char *argv[])
{
const char *config_file = argc > 1 ? argv[1] : "../config.json";
for (int i = 0; i < 10; i++)
discord_timer(client, on_timer_tick, on_timer_status_changed, NULL,
i * 1000);
NULL, 0, 1000, 10);
discord_timer(client, use_same_function, use_same_function, malloc(1024),
1000);
client, use_same_function, use_same_function, malloc(1024), 1000);
}
CCORDcode ccord_global_init()
Initialize global shared-resources not API-specific.
void ccord_global_cleanup()
Cleanup global shared-resources.
Public functions and datatypes.
void discord_cleanup(struct discord *client)
Free a Discord Client handle.
CCORDcode discord_run(struct discord *client)
Start a connection to the Discord Gateway.
struct discord * discord_config_init(const char config_file[])
Create a Discord Client handle by a config.json file.
bool discord_timer_cancel(struct discord *client, unsigned id)
cancels a timer, this will delete the timer if DISCORD_TIMER_DELETE_AUTO is enabled
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
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
@ DISCORD_TIMER_TICK
Definition: discord.h:365
@ DISCORD_TIMER_CANCELED
Definition: discord.h:363
@ DISCORD_TIMER_DELETE
Definition: discord.h:359
struct used for modifying, and getting info about a timer
Definition: discord.h:373
void * data
Definition: discord.h:384
enum discord_timer_flags flags
Definition: discord.h:377
unsigned id
Definition: discord.h:375
int64_t interval
Definition: discord.h:388
int64_t repeat
Definition: discord.h:390
int64_t delay
Definition: discord.h:386
The Discord client handler.
Definition: discord-internal.h:1190