Orca
A bot framework that is easy to reason about, easy to debug, and easy to use.
|
File containing internal functions and datatypes. More...
#include <inttypes.h>
#include <pthread.h>
#include "uthash.h"
#include "json-scanf.h"
#include "json-actor.h"
#include "json-actor-boxed.h"
#include "logconf.h"
#include "user-agent.h"
#include "websockets.h"
#include "cee-utils.h"
#include "discord-voice-connections.h"
Go to the source code of this file.
Classes | |
struct | discord_adapter |
The handle used for performing HTTP Requests. More... | |
struct | discord_bucket |
The bucket struct that will handle ratelimiting. More... | |
struct | discord_gateway_cmd_cbs |
struct | discord_gateway |
The handle used for establishing a Discord Gateway connection via WebSockets. More... | |
struct | discord |
The Discord Client structure. More... | |
struct | discord_event_cxt |
Macros | |
#define | NUM_VCS 512 |
Functions | |
void | discord_adapter_init (struct discord_adapter *adapter, struct logconf *config, struct sized_buffer *token) |
Initialize the fields of a Discord Adapter handle. More... | |
void | discord_adapter_cleanup (struct discord_adapter *adapter) |
Free a Discord Adapter handle. More... | |
ORCAcode | discord_adapter_run (struct discord_adapter *adapter, struct ua_resp_handle *resp_handle, struct sized_buffer *req_body, enum http_method http_method, char endpoint[],...) |
Start a HTTP Request to Discord. More... | |
void | discord_buckets_cleanup (struct discord_adapter *adapter) |
Free client buckets. More... | |
void | discord_bucket_try_cooldown (struct discord_bucket *bucket) |
Check bucket for ratelimit cooldown. More... | |
struct discord_bucket * | discord_bucket_try_get (struct discord_adapter *adapter, const char route[]) |
Get existing bucket with route . More... | |
void | discord_bucket_build (struct discord_adapter *adapter, struct discord_bucket *bucket, const char route[], struct ua_info *info) |
Update the bucket with response header data. More... | |
void | discord_gateway_init (struct discord_gateway *gw, struct logconf *config, struct sized_buffer *token) |
Initialize the fields of Discord Gateway handle. More... | |
void | discord_gateway_cleanup (struct discord_gateway *gw) |
Free a Discord Gateway handle. More... | |
void | discord_gateway_run (struct discord_gateway *gw) |
Start a Discord connection over WebSockets. More... | |
void | discord_gateway_shutdown (struct discord_gateway *gw) |
Gracefully exits a ongoing Discord connection over WebSockets. More... | |
void | discord_gateway_reconnect (struct discord_gateway *gw, bool resume) |
Gracefully reconnect a ongoing Discord connection over WebSockets. More... | |
File containing internal functions and datatypes.
void discord_adapter_cleanup | ( | struct discord_adapter * | adapter | ) |
Free a Discord Adapter handle.
adapter | a pointer to the adapter handle |
void discord_adapter_init | ( | struct discord_adapter * | adapter, |
struct logconf * | config, | ||
struct sized_buffer * | token | ||
) |
Initialize the fields of a Discord Adapter handle.
adapter | a pointer to the allocated handle |
config | optional pointer to a pre-initialized logconf |
token | the bot token |
ORCAcode discord_adapter_run | ( | struct discord_adapter * | adapter, |
struct ua_resp_handle * | resp_handle, | ||
struct sized_buffer * | req_body, | ||
enum http_method | http_method, | ||
char | endpoint[], | ||
... | |||
) |
Start a HTTP Request to Discord.
adapter | the handle initialized with discord_adapter_init() |
resp_handle | the callbacks that will be triggered should the request fail or succeed |
req_body | the body sent for methods that require (ex: POST), leave as NULL if unecessary |
http_method | the method in opcode format of the request being sent |
endpoint | the format endpoint that be appended to base_url when performing a request, same behavior as printf() |
void discord_bucket_build | ( | struct discord_adapter * | adapter, |
struct discord_bucket * | bucket, | ||
const char | route[], | ||
struct ua_info * | info | ||
) |
Update the bucket with response header data.
adapter | the handle created with discord_adapter_init() |
bucket | NULL when bucket is first discovered |
route | the route associated with the bucket |
info | information struct regarding the current transfer |
void discord_bucket_try_cooldown | ( | struct discord_bucket * | bucket | ) |
Check bucket for ratelimit cooldown.
Check if connections from a bucket hit its threshold, and lock every connection associated with the bucket until cooldown time elapses
bucket | check if a cooldown is necessary |
struct discord_bucket* discord_bucket_try_get | ( | struct discord_adapter * | adapter, |
const char | route[] | ||
) |
Get existing bucket with route
.
Check if bucket associated with route
has already been discovered
adapter | the handle created with discord_adapter_init() |
route | that will be checked for a bucket match |
void discord_buckets_cleanup | ( | struct discord_adapter * | adapter | ) |
Free client buckets.
adapter | the client adapter containinig every bucket found |
void discord_gateway_cleanup | ( | struct discord_gateway * | gw | ) |
Free a Discord Gateway handle.
gw | a pointer to the gateway handle |
void discord_gateway_init | ( | struct discord_gateway * | gw, |
struct logconf * | config, | ||
struct sized_buffer * | token | ||
) |
Initialize the fields of Discord Gateway handle.
gw | a pointer to the allocated handle |
config | optional pointer to a initialized logconf |
token | the bot token |
void discord_gateway_reconnect | ( | struct discord_gateway * | gw, |
bool | resume | ||
) |
Gracefully reconnect a ongoing Discord connection over WebSockets.
gw | the handle initialized with discord_gateway_init() |
resume | true to attempt to resume to previous session, false restart a fresh session |
void discord_gateway_run | ( | struct discord_gateway * | gw | ) |
Start a Discord connection over WebSockets.
gw | the handle initialized with discord_gateway_init() |
void discord_gateway_shutdown | ( | struct discord_gateway * | gw | ) |
Gracefully exits a ongoing Discord connection over WebSockets.
gw | the handle initialized with discord_gateway_init() |