Commit Graph

15 Commits

Author SHA1 Message Date
diamondburned 54cadd2f45 gateway: Refactor for a better concurrent API
This commit refactors the whole package gateway as well as utils/ws
(formerly utils/wsutil) and voice/voicegateway. The new refactor
utilizes a design pattern involving a concurrent loop and an arriving
event channel.

An additional change was made to the way gateway events are typed.
Before, pretty much any type will satisfy a gateway event type, since
the actual type was just interface{}. The new refactor defines a
concrete interface that events can implement:

    type Event interface {
        Op() OpCode
        EventType() EventType
    }

Using this interface, the user can easily add custom gateway events
independently of the library without relying on string maps. This adds a
lot of type safety into the library and makes type-switching on Event
types much more reasonable.

Gateway error callbacks are also almost entirely removed in favor of
custom gateway events. A catch-all can easily be added like this:

    s.AddHandler(func(err error) {
        log.Println("gateway error:, err")
    })
2021-12-14 13:49:34 -08:00
diamondburned 0d13edc8fd
gateway: Add ClientState and Capabilities for Identify
This commit preps the gateway for user account usage.
2021-11-03 15:29:29 -07:00
samhza 4023a58f67
gateway: Change type of IdentifyData.Intents to option.Uint (#275) 2021-09-09 18:45:08 -07:00
diamondburned 05de2d7b61 Gateway: Made Shard field empty for default 2020-12-30 23:43:08 -08:00
diamondburned 5e2af90fd0 Gateway: Rollback weird user changes 2020-12-01 18:07:42 -08:00
diamondburned 6ef093eb98 Gateway: Refactor, v8 user struct updates
This commit refactored several structures from package discord to be in
package gateway. Those structures are mostly presence ones, which per
official documentation has a lot more to do with the Gateway API than
the REST API or anything else.

This commit also renamed several global variables to have a more
consistent and obvious name.

As of v8, the user API has had a lot of minor and some major changes,
especially regarding its Ready event API. The most significant change is
the addition of the ReadySupplemental event as well as several changes
to the Ready field itself.

All of these changes above are breaking, and they have already broken
the state package. These breaking changes will be addressed in other
packages by the next commit.
2020-11-28 17:22:03 -08:00
mavolin aff386402f Gateway: remove GuildSubscriptions from IdentifyData
With the requirement of intents on Gateway v8, the guild_subscriptions field has no effect, and is therefore removed
2020-11-03 10:18:04 -08:00
diamondburned b8e4b2cf56 Gateway: Added an Event to Intents map for convenience 2020-10-28 19:44:04 -07:00
diamondburned edb8a46ef2 Gateway: Added intent helpers and more context API support 2020-07-11 12:50:32 -07:00
mavolin 41ce1f389e
make all error messages lowercase 2020-05-16 23:14:49 +02:00
diamondburned (Forefront) 748ad5641c API: Added AllowedMentions and more tests 2020-04-19 16:35:37 -07:00
diamondburned (Forefront) f0102d765f Gateway: Added a retry limit
State: Event handlers now handle all of Ready's Guilds field
Session: Added Wait, which blocks until SIGINT or Gateway error
2020-02-29 18:13:58 -08:00
diamondburned (Forefront) ce59298937 Gateway: Changed Intents' type from uint16 to uint32 for future constants 2020-02-21 23:38:51 -08:00
diamondburned (Forefront) 64aca9ea40 Gateway: Prepare for the new intents update
https://discordapp.com/developers/docs/topics/gateway#gateway-intents
2020-02-21 23:35:11 -08:00
diamondburned (Forefront) 03d226e23d WIP integration test 2020-01-14 23:34:18 -08:00