Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0.0 #66

Closed
wants to merge 116 commits into from
Closed

V2.0.0 #66

wants to merge 116 commits into from

Conversation

lcsmuller
Copy link
Collaborator

@lcsmuller lcsmuller commented May 9, 2022

See Also

#69

What?

  1. Breaking changes
    1.1. Struct wrapping of callback parameters
    1.2. Requests are now performed in enqueue order
    1.3. Replace DISCORD_GATEWAY_EVENTS_* macro prefix with DISCORD_EV_*
    1.4. Rewrite discord_set_on_commands() function signature
  2. Features
    2.1. Add functions for all Gateway commands
    2.2. Add discord_claim() and discord_unclaim() to grant client's ownership of Concord parameters, and override automatic cleanup
  3. Bug Fixes
    3.1. Regression where WebSockets sessions were not being resumed
    3.2. Requests can now be sent in parallel even while there are requests being performed from the main-thread
  4. Improve modularization and reduce code duplication for discord-gateway.c
  5. Ratelimiting rewrite using the Timer API from Timer Wrapper Functions, and Refactoring #58
  6. Rewrite Message Commands handling to perform its register and search operations on a hashtable
  7. Showcase minimalistic slash-commands usage at README.md
  8. Replace all Adapter references with REST

Why?

  1. Breaking changes
    1.1. Struct wrapping of callback parameters
  • Adding extra fields to structs won't break future builds, but adding extra parameters to a function would. Event data are now wrapped and accessed from structs
  • The callbacks struct's ownership can now be granted to the user and passed around different callbacks, removing the complexity of having to create duplicates
    1.2. It is intuitively expected that the order of requests respects the order of their enqueue
    1.3. Reduce length for macros that are very often used
    1.4. The previous method of NULL-terminating a va_list of message commands was non-intuitive
  1. Features
    2.1. On-going effort of covering the entire Discord API
    2.2. Allows client to keep ownership of Concord callback's parameter, rather than having to tediously clone the data of interest if they wanted to keep it between callbacks
  2. Bug Fixes
    3.1. Sessions should be resumed when possible, rather than starting a new one on every reconnect
    3.2. Before user had to opt between choosing between synchronous or asynchronous requests, now they can do both simultaneously
  3. Improve navigation by splitting discord-gateway.c into smaller files
  4. Use of Concord's Timer API for Ratelimiting will ensure any regressions are swiftly noticed
  5. Keep its interface familiar discord-rest_ratelimit.c and discord-refcount.c
  6. Showcase slash-commands support and how to get started with a minimum reproducible example
  7. Adapter was a misnomer back from Orca development, replacing it with REST gives a better description of it being a interface to the Discord's REST API

How?

  1. Breaking changes
    1.1. By wrapping callback parameters in structs:
    before v2.0.0

    void on_message_reaction_add(struct discord *client,
                                 u64snowflake user_id,
                                 u64snowflake channel_id,
                                 u64snowflake message_id,
                                 u64snowflake guild_id,
                                 const struct discord_guild_member *member,
                                 const struct discord_emoji *emoji)
    {
        printf("%lld\n", user_id); 
    }
    
    void on_message_delete_bulk(struct discord *client,
                                const struct snowflakes *ids,
                                u64snowflake channel_id,
                                u64snowflake guild_id)
    {
        if (ids->size)
            printf("%lld\n", ids->array[0]); 
    }

    after v2.0.0

    void on_message_reaction_add(struct discord *client, const struct discord_message_reaction_add *event)
    {
        printf("%lld\n", event->user_id); 
    }
    
    void on_message_delete_bulk(struct discord *client,
                                const struct discord_message_delete_bulk *event)
    {
        if (event->ids->size)
            printf("%lld\n", event->ids->array[0]);
    }

1.2. By limiting to only one request per-bucket being sent at a time
1.3. Edit previous macros at gencodecs/api/gateway.pre.h
1.4. Rewrite discord_set_on_commands() function signature
before v2.0.0

discord_set_on_commands(client, callback, "foo", "bar", "baz", NULL);

after v2.0.0

char *cmds[] = { "foo", "bar", "baz" };
discord_set_on_commands(client, cmds, sizeof(cmds) / sizeof *cmds, callback);
  1. Features
    2.1. See 1498dc3
    2.2. Add discord_claim() and discord_unclaim() to grant client's ownership of Concord parameters, and override automatic cleanup
  2. See 23f03b7
  3. See f3e9ba5

lcsmuller added 29 commits May 2, 2022 23:22
'struct discord'
* fix: replace outdated references to HAS_DISCORD_VOICE with CCORD_VOICE
discord_update_voice_state() and discord_update_presence()
* feat(discord-gateway): implement all Gateway Commands and refactor
  existing ones for consistency
…eway_command.c, update structures and methods accordingly
@lcsmuller lcsmuller added the bug Something isn't working label May 9, 2022
@lcsmuller lcsmuller added the bug Something isn't working label Jun 1, 2022
@lcsmuller lcsmuller changed the base branch from dev to master June 8, 2022 17:32
@lcsmuller lcsmuller changed the base branch from master to dev June 8, 2022 17:39
@lcsmuller lcsmuller marked this pull request as ready for review June 8, 2022 17:39
@lcsmuller lcsmuller changed the base branch from dev to master June 8, 2022 17:41
@lcsmuller lcsmuller closed this Jun 8, 2022
@lcsmuller lcsmuller deleted the v2.0.0 branch June 8, 2022 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request missing feature Missing Discord API feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants