Concord - C Discord API library
A Discord API wrapper library written in C
discord-internal.h
Go to the documentation of this file.
1
8#ifndef DISCORD_INTERNAL_H
9#define DISCORD_INTERNAL_H
10
11#ifdef __cplusplus
12extern "C" {
13#endif /* __cplusplus */
14
15#include <pthread.h>
16
17#define JSONB_HEADER
18#include "json-build.h"
19#define JSMN_STRICT
20#define JSMN_HEADER
21#include "jsmn.h"
22#include "jsmn-find.h"
23#define LOGMOD_HEADER
24#include "logmod.h"
25
26#include "user-agent.h"
27#include "websockets.h"
28#include "cog-utils.h"
29#include "io_poller.h"
30#include "queue.h"
31#include "priority_queue.h"
32#include "attributes.h"
33
39#define NOT_EMPTY_STR(_str) ((_str) && *(_str))
47#define CONTAINEROF(_ptr, _type, _path) \
48 ((_type *)((char *)(_ptr) - offsetof(_type, _path)))
49
60#define CLIENT(_ptr, _path) CONTAINEROF(_ptr, struct discord, _path)
61
71#define CCORD_EXPECT(_client, _expect, _code, _reason) \
72 do { \
73 if (!(_expect)) { \
74 logmod_log(ERROR, (_client)->logger, \
75 "Expected: " #_expect " | %s (%s)", \
76 discord_strerror(_code, _client), \
77 discord_code_as_string(_code)); \
78 return _code; \
79 } \
80 } while (0)
81
91#define CCORD_DATA_TO_JSON(_client, _type, _body, _params) \
92 do { \
93 struct reflectc_wrap *w_params = \
94 reflectc_from_##_type((_client)->registry, _params, NULL); \
95 CCORDcode code = discord_data_wrap_to_json(w_params, &(_body)->start, \
96 &(_body)->size); \
97 reflectc_cleanup((_client)->registry, w_params); \
98 if (code != CCORD_OK) { \
99 logmod_log(ERROR, (_client)->logger, \
100 "Expected: CCORD_OK == discord_data_wrap_to_json | " \
101 "%s (%s)", \
102 discord_strerror(code, _client), \
103 discord_code_as_string(code)); \
104 return code; \
105 } \
106 } while (0)
107
109#define DISCORD_ENDPT_LEN 512
111#define DISCORD_ROUTE_LEN 256
112
119 struct io_poller *io;
120 struct {
122 pthread_t thread;
126 pthread_mutex_t lock;
127 pthread_cond_t cond;
128};
129
137 struct io_poller *io);
138
145void discord_timers_cleanup(struct discord *client,
146 struct discord_timers *timers);
147
157int64_t discord_timers_get_next_trigger(struct discord_timers *const timers[],
158 size_t n,
159 int64_t now,
160 int64_t max_time);
161
168void discord_timers_run(struct discord *client, struct discord_timers *timers);
169
178unsigned _discord_timer_ctl(struct discord *client,
179 struct discord_timers *timers,
180 struct discord_timer *timer);
181
189unsigned discord_internal_timer_ctl(struct discord *client,
190 struct discord_timer *timer);
191
205unsigned discord_internal_timer(struct discord *client,
206 discord_ev_timer on_tick_cb,
207 discord_ev_timer on_status_changed_cb,
208 void *data,
209 int64_t delay);
210
229#define DISCORD_BUCKET_TIMEOUT (void *)(0xf)
230
246 struct _discord_route *routes;
253
254 /* client-wide global ratelimiting */
256
258 struct {
260 QUEUE(struct discord_bucket) pending;
262};
263
272
280
290void discord_ratelimiter_build_key(enum http_method method,
291 char key[DISCORD_ROUTE_LEN],
292 const char endpoint_fmt[],
293 va_list args);
294
305 struct discord_bucket *bucket,
306 const char key[],
307 struct ua_info *info);
308
318 struct discord_bucket *bucket,
319 u64unix_ms wait_ms);
320
324 char hash[64];
326 long limit;
331
337
339 struct {
341 QUEUE(struct discord_request) next;
345};
346
354 u64unix_ms wait_ms);
355
364 const char key[]);
365
376 struct discord_bucket *b,
377 struct discord_request *req,
378 bool high_priority);
379
390 struct discord_ratelimiter *rl,
391 void *data,
392 void (*iter)(void *data, struct discord_request *req));
393
403 struct discord_bucket *b,
404 struct discord_request *req);
405
413
419 union {
420 void (*typed)(struct discord *client,
421 struct discord_response *resp,
422 const void *ret);
423 void (*typeless)(struct discord *client,
424 struct discord_response *resp);
426
430 void *sync;
431};
432
436 void *data;
438 size_t size;
440 struct reflectc_wrap *(*init)(struct reflectc *registry,
441 void *data,
442 struct reflectc_wrap *root);
443};
444
449#define DISCORD_ATTRIBUTES_FIELDS \
450 \
451 struct discord_ret_dispatch dispatch; \
452 \
453 struct discord_ret_response response; \
454 \
455 struct discord_attachments attachments; \
456 \
458 char *reason
459
463};
464
473
475 struct discord_bucket *b;
477 struct ccord_szbuf body;
479 enum http_method method;
485 struct ua_conn *conn;
491 int retry_attempt;
493 pthread_cond_t *cond;
495 QUEUE entry;
496};
497
499struct discord_requestor {
501 struct logmod_logger *logger;
503 struct user_agent *ua;
505 CURLM *mhandle;
508
510 int retry_limit;
511
513 struct {
523 } *queues;
524
526 struct {
528 pthread_mutex_t recycling;
530 pthread_mutex_t pending;
532 pthread_mutex_t finished;
533 } *qlocks;
534};
535
546 const char token[]);
547
554
562
570
577
585 struct discord_request *req);
586
601 const struct discord_attributes *req,
602 const struct ccord_szbuf *body,
603 const enum http_method method,
604 const char endpoint[DISCORD_ENDPT_LEN],
605 const char key[DISCORD_ROUTE_LEN]);
606
615struct discord_rest {
617 struct logmod_logger *logger;
621 struct discord_timers timers;
623 struct io_poller *io_poller;
625 struct threadpool_t *tpool;
626};
627
636CCORDcode discord_rest_init(struct discord_rest *rest, const char token[]);
637
643void discord_rest_cleanup(struct discord_rest *rest);
644
661 const struct discord_attributes *req,
662 const struct ccord_szbuf *body,
663 const enum http_method method,
664 const char endpoint_fmt[],
665 ...) PRINTF_LIKE(5, 6);
666
673void discord_rest_stop_buckets(struct discord_rest *rest);
674
685#define DISCORD_SESSION_OFFLINE 0u
687#define DISCORD_SESSION_RESUMABLE 1u << 0
689#define DISCORD_SESSION_SHUTDOWN 1u << 1
695 bool is_ready;
697 char id[64];
699 int shards;
701 char base_url[256];
703 char resume_url[256];
705 struct discord_session_start_limit start_limit;
707 int concurrent;
709 int event_count;
711 unsigned status;
712
714 struct {
716 bool enable;
718 int attempt;
720 int limit;
721 } retry;
722};
723
727 struct {
729 char *start;
731 size_t size;
733 jsmnf_table *table;
735 size_t ntable;
736 } json;
737
739 enum discord_gateway_opcodes opcode;
741 int seq;
743 char name[32];
747 const jsmnf_pair *data;
748};
749
751typedef void (*discord_ev_event)(struct discord *client, const void *event);
753typedef void (*discord_ev_message)(struct discord *client,
754 const struct discord_message *event);
755
757struct discord_gateway {
759 struct logmod_logger *logger;
761 struct websockets *ws;
763 CURLM *mhandle;
764
766 struct {
771 int64_t hbeat_interval;
799 unsigned hbeat_timer;
800
805 int ping_ms;
807 pthread_rwlock_t rwlock;
808 } *timer;
809
811 struct discord_identify id;
812
815
827};
828
837CCORDcode discord_gateway_init(struct discord_gateway *gw, const char token[]);
838
845
853
861bool discord_gateway_end(struct discord_gateway *gw);
862
870
877
885void discord_gateway_reconnect(struct discord_gateway *gw, bool resume);
886
894 struct discord_identify *event);
895
903 struct discord_resume *event);
904
912
921
931
939 struct discord_gateway *gw, struct discord_presence_update *event);
940
947
961struct discord_refcounter {
963 struct logmod_logger *logger;
965 int length;
967 int capacity;
972 struct _discord_ref *refs;
974 pthread_mutex_t *g_lock;
975};
976
985
996 void *data,
997 void (*cleanup)(void *data),
998 bool should_free);
999
1010 void *data,
1011 void (*cleanup)(struct discord *client,
1012 void *data),
1013 bool should_free);
1014
1021
1035 const void *data);
1036
1050 void *data);
1051
1062
1077
1090 const struct logmod_logger *logger;
1092 struct ccord_szbuf prefix;
1096 int length;
1098 int capacity;
1103 struct _discord_message_commands_entry *entries;
1104};
1105
1113
1120
1130 struct discord_message_commands *cmds,
1131 const char command[],
1132 size_t length);
1133
1143 const char command[],
1144 size_t length,
1145 discord_ev_message callback);
1146
1158 const char prefix[],
1159 size_t length);
1160
1171 struct discord_message_commands *cmds,
1172 struct discord_gateway_payload *payload);
1173
1184 struct _discord_cache_data *data;
1185 void (*cleanup)(struct discord *client);
1186
1188 void (*on_shard_disconnected)(struct discord *client,
1189 const struct discord_identify *ident,
1190 bool resumable);
1192 void (*on_shard_resumed)(struct discord *client,
1193 const struct discord_identify *ident);
1195 void (*on_shard_reconnected)(struct discord *client,
1196 const struct discord_identify *ident);
1197};
1198
1207struct discord {
1213 struct reflectc *registry;
1215 struct logmod_logger *logger;
1217 struct logmod_logger table[64];
1219 struct logmod logmod;
1221 struct discord_config config;
1223 unsigned pid;
1225 bool is_original;
1227 struct io_poller *io_poller;
1228
1233
1235 struct discord_rest rest;
1237 struct discord_gateway gw;
1239 struct discord_user self;
1241 struct discord_cache cache;
1242
1244 int shutdown_fd;
1245
1246 struct {
1249 } timers;
1250
1252 void (*on_idle)(struct discord *client);
1254 void (*on_cycle)(struct discord *client);
1255
1257 void *data;
1258
1260 struct {
1262 int count;
1264 pthread_mutex_t lock;
1266 pthread_cond_t cond;
1267 } *workers;
1268
1271 struct ccord_szbuf file;
1272};
1273
1276#ifdef __cplusplus
1277}
1278#endif /* __cplusplus */
1279
1280#endif /* DISCORD_INTERNAL_H */
#define PRINTF_LIKE(a, b)
Definition: attributes.h:9
int CCORDcode
Concord error codes.
Definition: concord-error.h:11
uint64_t u64unix_ms
Unix time in milliseconds.
Definition: types.h:22
void discord_update_voice_state(struct discord *client, struct discord_update_voice_state *update)
Sent when a client wants to join, move or disconnect from a voice channel.
void discord_request_guild_members(struct discord *client, struct discord_request_guild_members *request)
Request all members for a guild or a list of guilds.
discord_gateway_events
Discord Gateway's events.
Definition: discord-events.h:54
enum discord_event_scheduler(* discord_ev_scheduler)(struct discord *client, const char data[], size_t size, enum discord_gateway_events event)
Event Handling Mode callback.
Definition: discord-events.h:141
@ DISCORD_EV_MAX
Definition: discord-events.h:118
void(* discord_ev_message)(struct discord *client, const struct discord_message *event)
Definition: discord-internal.h:752
void discord_gateway_reconnect(struct discord_gateway *gw, bool resume)
Gracefully reconnect a ongoing Discord connection over WebSockets.
void discord_gateway_send_update_voice_state(struct discord_gateway *gw, struct discord_update_voice_state *event)
Sent when a client wants to join, move or disconnect from a voice channel.
CCORDcode discord_gateway_start(struct discord_gateway *gw)
Initialize handle with the new session primitives.
void discord_gateway_dispatch(struct discord_gateway *gw)
Dispatch user callback matched to event.
bool discord_gateway_end(struct discord_gateway *gw)
Cleanup and reset gw session primitives.
void discord_gateway_shutdown(struct discord_gateway *gw)
Gracefully shutdown a ongoing Discord connection over WebSockets.
CCORDcode discord_gateway_perform(struct discord_gateway *gw)
Check and manage on-going Gateway session.
void discord_gateway_send_resume(struct discord_gateway *gw, struct discord_resume *event)
Replay missed events when a disconnected client resumes.
void discord_gateway_send_request_guild_members(struct discord_gateway *gw, struct discord_request_guild_members *event)
Request all members for a guild or a list of guilds.
void discord_gateway_cleanup(struct discord_gateway *gw)
Free a Gateway handle.
void discord_gateway_send_presence_update(struct discord_gateway *gw, struct discord_presence_update *event)
Send client's presence status update payload.
CCORDcode discord_gateway_init(struct discord_gateway *gw, const char token[])
Initialize a Gateway handle.
void discord_gateway_send_heartbeat(struct discord_gateway *gw, int seq)
Maintain an active gateway connection.
void discord_gateway_send_identify(struct discord_gateway *gw, struct discord_identify *event)
Trigger the initial handshake with the gateway.
void(* discord_ev_event)(struct discord *client, const void *event)
Definition: discord-internal.h:750
CCORDcode discord_message_commands_init(struct discord_message_commands *cmds)
Initialize a Message Commands handle.
void discord_message_commands_set_prefix(struct discord_message_commands *cmds, const char prefix[], size_t length)
Set a mandatory prefix before commands.
void discord_message_commands_append(struct discord_message_commands *cmds, const char command[], size_t length, discord_ev_message callback)
Add a new command/callback pair, or update an existing command.
discord_ev_message discord_message_commands_find(struct discord_message_commands *cmds, const char command[], size_t length)
Search for a callback matching the command.
bool discord_message_commands_try_perform(struct discord_message_commands *cmds, struct discord_gateway_payload *payload)
Read the current DISCORD_EV_MESSAGE_CREATE payload and attempt to perform its matching callback.
void discord_message_commands_cleanup(struct discord_message_commands *cmds)
Free a Message Commands handle.
void discord_ratelimiter_set_global_timeout(struct discord_ratelimiter *rl, struct discord_bucket *bucket, u64unix_ms wait_ms)
Update global ratelimiting value.
void discord_ratelimiter_build(struct discord_ratelimiter *rl, struct discord_bucket *bucket, const char key[], struct ua_info *info)
Update the bucket with response header data.
void discord_ratelimiter_build_key(enum http_method method, char key[256], const char endpoint_fmt[], va_list args)
Build unique key formed from the HTTP method and endpoint.
void discord_bucket_request_unselect(struct discord_ratelimiter *rl, struct discord_bucket *b, struct discord_request *req)
Unselect a request provided at discord_ratelimiter_request_selector()
void discord_bucket_insert(struct discord_ratelimiter *rl, struct discord_bucket *b, struct discord_request *req, bool high_priority)
Insert into bucket's next requests queue.
void discord_ratelimiter_cleanup(struct discord_ratelimiter *rl)
Cleanup all buckets that have been discovered.
void discord_bucket_set_timeout(struct discord_bucket *bucket, u64unix_ms wait_ms)
Set bucket timeout.
struct discord_bucket * discord_bucket_get(struct discord_ratelimiter *rl, const char key[])
Get a struct discord_bucket assigned to key
void discord_bucket_request_selector(struct discord_ratelimiter *rl, void *data, void(*iter)(void *data, struct discord_request *req))
Iterate and select next requests.
CCORDcode discord_ratelimiter_init(struct discord_ratelimiter *rl)
Initialize ratelimiter handle.
CCORDcode discord_requestor_init(struct discord_requestor *rqtor, const char token[])
Initialize the request handler.
void discord_requestor_dispatch_responses(struct discord_requestor *rqtor)
Run pending callbacks from completed requests.
CCORDcode discord_requestor_start_pending(struct discord_requestor *rqtor)
Check for and start pending bucket's requests.
#define DISCORD_ATTRIBUTES_FIELDS
Macro containing discord_attributes fields.
Definition: discord-internal.h:449
CCORDcode discord_requestor_info_read(struct discord_requestor *rqtor)
Poll for request's completion.
CCORDcode discord_request_begin(struct discord_requestor *rqtor, const struct discord_attributes *req, const struct ccord_szbuf *body, const enum http_method method, const char endpoint[512], const char key[256])
Begin a new request.
void discord_request_cancel(struct discord_requestor *rqtor, struct discord_request *req)
Mark request as canceled and move it to the recycling queue.
void discord_requestor_cleanup(struct discord_requestor *rqtor)
Free the request handler.
CCORDcode discord_rest_init(struct discord_rest *rest, const char token[])
Initialize an REST handle.
void discord_rest_cleanup(struct discord_rest *rest)
Free an REST handle.
CCORDcode discord_rest_run(struct discord_rest *rest, const struct discord_attributes *req, const struct ccord_szbuf *body, const enum http_method method, const char endpoint_fmt[],...) PRINTF_LIKE(5
Perform a request to Discord.
CCORDcode void discord_rest_stop_buckets(struct discord_rest *rest)
Stop all bucket's on-going, pending and timed-out requests.
CCORDcode discord_refcounter_unclaim(struct discord_refcounter *rc, void *data)
Unclaim ownership of data
CCORDcode discord_refcounter_claim(struct discord_refcounter *rc, const void *data)
Claim ownership of data
void discord_refcounter_cleanup(struct discord_refcounter *rc)
Cleanup refcounter and all user data currently held.
CCORDcode discord_refcounter_incr(struct discord_refcounter *rc, void *data)
Increment the reference counter for ret->data
void discord_refcounter_add_internal(struct discord_refcounter *rc, void *data, void(*cleanup)(void *data), bool should_free)
Add a new internal reference to the reference counter.
CCORDcode discord_refcounter_decr(struct discord_refcounter *rc, void *data)
Decrement the reference counter for data
CCORDcode discord_refcounter_init(struct discord_refcounter *rc)
Initialize reference counter handle.
void discord_refcounter_add_client(struct discord_refcounter *rc, void *data, void(*cleanup)(struct discord *client, void *data), bool should_free)
Add a new client reference to the reference counter.
int64_t discord_timers_get_next_trigger(struct discord_timers *const timers[], size_t n, int64_t now, int64_t max_time)
Get earliest trigger time from a group of timers.
unsigned discord_internal_timer_ctl(struct discord *client, struct discord_timer *timer)
Modifies or creates a timer.
unsigned _discord_timer_ctl(struct discord *client, struct discord_timers *timers, struct discord_timer *timer)
Modifies or creates a timer.
void discord_timers_cleanup(struct discord *client, struct discord_timers *timers)
Cleanup timers and call cancel any running ones.
void discord_timers_run(struct discord *client, struct discord_timers *timers)
Run all timers that are due.
CCORDcode discord_timers_init(struct discord_timers *timers, struct io_poller *io)
Prepare timers for usage.
unsigned discord_internal_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.
#define DISCORD_ROUTE_LEN
Definition: discord-internal.h:111
#define DISCORD_ENDPT_LEN
Definition: discord-internal.h:109
void(* discord_ev_timer)(struct discord *client, struct discord_timer *ev)
callback to be used with struct discord_timer
Definition: discord.h:654
struct priority_queue priority_queue
Definition: priority_queue.h:13
void * QUEUE[2]
Definition: queue.h:21
Read-only generic sized buffer.
Definition: types.h:57
Generic sized buffer.
Definition: types.h:47
Request to be performed.
Definition: discord-internal.h:460
The Discord bucket for handling per-group ratelimits.
Definition: discord-internal.h:322
u64unix_ms reset_tstamp
Definition: discord-internal.h:330
struct discord_request * busy_req
Definition: discord-internal.h:336
long limit
Definition: discord-internal.h:326
long remaining
Definition: discord-internal.h:328
char hash[64]
Definition: discord-internal.h:324
QUEUE entry
Definition: discord-internal.h:344
struct discord_bucket::@4 queues
The Discord Cache control handler.
Definition: discord-internal.h:1182
void(* on_shard_resumed)(struct discord *client, const struct discord_identify *ident)
Definition: discord-internal.h:1191
struct _discord_cache_data * data
Definition: discord-internal.h:1183
void(* on_shard_disconnected)(struct discord *client, const struct discord_identify *ident, bool resumable)
Definition: discord-internal.h:1187
void(* cleanup)(struct discord *client)
Definition: discord-internal.h:1184
void(* on_shard_reconnected)(struct discord *client, const struct discord_identify *ident)
Definition: discord-internal.h:1194
The Discord configuration handler.
Definition: discord.h:250
The handle for storing the Discord response payload.
Definition: discord-internal.h:724
const jsmnf_pair * data
Definition: discord-internal.h:746
size_t ntable
Definition: discord-internal.h:734
struct discord_gateway_payload::@9 json
jsmnf_table * table
Definition: discord-internal.h:732
size_t size
Definition: discord-internal.h:730
int seq
Definition: discord-internal.h:740
char * start
Definition: discord-internal.h:728
enum discord_gateway_events event
Definition: discord-internal.h:744
char name[32]
Definition: discord-internal.h:742
enum discord_gateway_opcodes opcode
Definition: discord-internal.h:738
The handle for storing the Discord Gateway session.
Definition: discord-internal.h:692
char base_url[256]
Definition: discord-internal.h:700
struct discord_session_start_limit start_limit
Definition: discord-internal.h:704
int limit
Definition: discord-internal.h:719
char resume_url[256]
Definition: discord-internal.h:702
int attempt
Definition: discord-internal.h:717
int shards
Definition: discord-internal.h:698
int event_count
Definition: discord-internal.h:708
unsigned status
Definition: discord-internal.h:710
struct discord_gateway_session::@8 retry
int concurrent
Definition: discord-internal.h:706
bool enable
Definition: discord-internal.h:715
bool is_ready
Definition: discord-internal.h:694
The handle used for interfacing with Discord's Gateway API.
Definition: discord-internal.h:756
struct websockets * ws
Definition: discord-internal.h:760
u64unix_ms hbeat_last
Definition: discord-internal.h:786
struct discord_gateway_payload payload
Definition: discord-internal.h:816
discord_ev_scheduler scheduler
Definition: discord-internal.h:825
unsigned hbeat_timer
Definition: discord-internal.h:798
u64unix_ms now
Definition: discord-internal.h:780
struct discord_gateway_session * session
Definition: discord-internal.h:813
int64_t hbeat_interval
Definition: discord-internal.h:770
pthread_rwlock_t rwlock
Definition: discord-internal.h:806
struct discord_gateway::@10 * timer
int ping_ms
Definition: discord-internal.h:804
u64unix_ms identify_last
Definition: discord-internal.h:791
struct logmod_logger * logger
Definition: discord-internal.h:758
u64unix_ms event
Definition: discord-internal.h:796
bool hbeat_acknowledged
Definition: discord-internal.h:775
CURLM * mhandle
Definition: discord-internal.h:762
struct discord_identify id
Definition: discord-internal.h:810
discord_ev_event cbs[2][DISCORD_EV_MAX]
Definition: discord-internal.h:823
The handle for storing user's message commands.
Definition: discord-internal.h:1087
const struct logmod_logger * logger
Definition: discord-internal.h:1089
struct _discord_message_commands_entry * entries
Definition: discord-internal.h:1102
discord_ev_message fallback
Definition: discord-internal.h:1093
int length
Definition: discord-internal.h:1095
struct ccord_szbuf prefix
Definition: discord-internal.h:1091
int capacity
Definition: discord-internal.h:1097
The ratelimiter struct for handling ratelimiting.
Definition: discord-internal.h:235
struct discord_bucket * null
Definition: discord-internal.h:249
struct discord_ratelimiter::@3 queues
u64unix_ms * global_wait_tstamp
Definition: discord-internal.h:255
struct logmod_logger * logger
Definition: discord-internal.h:237
int length
Definition: discord-internal.h:239
struct discord_bucket * miss
Definition: discord-internal.h:252
int capacity
Definition: discord-internal.h:241
struct _discord_route * routes
Definition: discord-internal.h:246
Automatically cleanup user data.
Definition: discord-internal.h:960
pthread_mutex_t * g_lock
Definition: discord-internal.h:973
struct _discord_ref * refs
Definition: discord-internal.h:971
int length
Definition: discord-internal.h:964
int capacity
Definition: discord-internal.h:966
struct logmod_logger * logger
Definition: discord-internal.h:962
Individual requests that are scheduled to run asynchronously.
Definition: discord-internal.h:470
QUEUE entry
Definition: discord-internal.h:494
struct ccord_szbuf body
Definition: discord-internal.h:476
pthread_cond_t * cond
Definition: discord-internal.h:492
enum http_method method
Definition: discord-internal.h:478
char endpoint[512]
Definition: discord-internal.h:480
int retry_attempt
Definition: discord-internal.h:490
char key[256]
Definition: discord-internal.h:482
struct discord_bucket * b
Definition: discord-internal.h:474
CCORDcode code
Definition: discord-internal.h:486
struct ua_conn * conn
Definition: discord-internal.h:484
struct ccord_szbuf_readonly json
Definition: discord-internal.h:488
The handle used for handling asynchronous requests.
Definition: discord-internal.h:498
pthread_mutex_t recycling
Definition: discord-internal.h:527
CURLM * mhandle
Definition: discord-internal.h:504
struct discord_requestor::@7 * qlocks
struct logmod_logger * logger
Definition: discord-internal.h:500
pthread_mutex_t finished
Definition: discord-internal.h:531
pthread_mutex_t pending
Definition: discord-internal.h:529
int retry_limit
Definition: discord-internal.h:509
struct user_agent * ua
Definition: discord-internal.h:502
struct discord_ratelimiter ratelimiter
Definition: discord-internal.h:506
struct discord_requestor::@6 * queues
The response for the completed request.
Definition: discord-response.h:12
The handle used for interfacing with Discord's REST API.
Definition: discord-internal.h:614
struct threadpool_t * tpool
Definition: discord-internal.h:624
struct logmod_logger * logger
Definition: discord-internal.h:616
struct io_poller * io_poller
Definition: discord-internal.h:622
struct discord_requestor requestor
Definition: discord-internal.h:618
struct discord_timers timers
Definition: discord-internal.h:620
Generic request dispatcher.
Definition: discord-internal.h:409
DISCORD_RET_DEFAULT_FIELDS
Definition: discord-internal.h:410
void(* typeless)(struct discord *client, struct discord_response *resp)
Definition: discord-internal.h:423
void * sync
Definition: discord-internal.h:430
bool has_type
Definition: discord-internal.h:412
void(* typed)(struct discord *client, struct discord_response *resp, const void *ret)
Definition: discord-internal.h:420
union discord_ret_dispatch::@5 done
Attributes of response datatype.
Definition: discord-internal.h:434
size_t size
Definition: discord-internal.h:438
void * data
Definition: discord-internal.h:436
struct used for modifying, and getting info about a timer
Definition: discord.h:678
void * data
Definition: discord.h:689
int64_t delay
Definition: discord.h:691
Definition: discord-internal.h:117
struct io_poller * io
Definition: discord-internal.h:119
pthread_mutex_t lock
Definition: discord-internal.h:126
bool skip_update_phase
Definition: discord-internal.h:124
struct discord_timers::@2 active
bool is_active
Definition: discord-internal.h:121
priority_queue * q
Definition: discord-internal.h:118
pthread_cond_t cond
Definition: discord-internal.h:127
struct discord_timer * timer
Definition: discord-internal.h:123
pthread_t thread
Definition: discord-internal.h:122
The Discord client handler.
Definition: discord-internal.h:1206
struct discord_user self
Definition: discord-internal.h:1238
struct discord::@12 * workers
struct discord::@11 timers
struct discord_cache cache
Definition: discord-internal.h:1240
void(* on_cycle)(struct discord *client)
Definition: discord-internal.h:1253
struct discord_message_commands commands
Definition: discord-internal.h:1229
struct logmod_logger * logger
Definition: discord-internal.h:1214
struct discord_rest rest
Definition: discord-internal.h:1234
struct reflectc * registry
Definition: discord-internal.h:1212
struct discord_refcounter refcounter
Definition: discord-internal.h:1231
struct io_poller * io_poller
Definition: discord-internal.h:1226
struct ccord_szbuf file
Definition: discord-internal.h:1270
unsigned pid
Definition: discord-internal.h:1222
struct discord_config config
Definition: discord-internal.h:1220
void(* on_idle)(struct discord *client)
Definition: discord-internal.h:1251
pthread_mutex_t lock
Definition: discord-internal.h:1263
bool is_original
Definition: discord-internal.h:1224
pthread_cond_t cond
Definition: discord-internal.h:1265
struct discord_timers internal
Definition: discord-internal.h:1246
struct logmod_logger table[64]
Definition: discord-internal.h:1216
struct discord_gateway gw
Definition: discord-internal.h:1236
void * data
Definition: discord-internal.h:1256
int shutdown_fd
Definition: discord-internal.h:1243
struct discord_timers user
Definition: discord-internal.h:1247
int count
Definition: discord-internal.h:1261
Immutable logger structure.
Definition: logmod.h:229
Main logging context structure.
Definition: logmod.h:240
Opaque handler for WebSockets.
struct threadpool_t threadpool_t
Definition: threadpool.h:48