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

Refactor the gateway to properly accept close frames #575

Merged
merged 11 commits into from
Nov 3, 2024

Conversation

kozabrada123
Copy link
Member

also introduces a test for receiving the close codes.

Differentiates the wasm and tungstenite gateways a bit more.

The same thing should be done for the voice gateway, I'll likely add it to this pr if the mod to the normal gateway is okay

Copy link
Member

@bitfl0wer bitfl0wer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Note: The tungstenite backend handles close codes as messages, while the ws_stream_wasm one handles them differently.

Since I have seen this comment in multiple files now: Would it perhaps be possible and feasible to convert wasm-stream and tungstenite messages into the same type? that way, we would not have to differentiate between the two in multiple files

@kozabrada123
Copy link
Member Author

That's how we used to do it; probably no, unless we have another task that just listens for ws_stream_wasm errors

@kozabrada123
Copy link
Member Author

How the messages are is represented currently: non error messages from tungstenite and ws_stream_wasm can both be RawGatewayMessage. GatewayCommunication are all tungstenite messages

@bitfl0wer
Copy link
Member

That's how we used to do it; probably no, unless we have another task that just listens for ws_stream_wasm errors

I meaaaan, that could work!

@kozabrada123
Copy link
Member Author

I think this is nicer
also, multiple files? they are twice in gateway.rs, and then in voice/gateway.rs (which is basically a copy of the former)

Copy link
Member

@bitfl0wer bitfl0wer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes! My only issue with them would be what I already mentioned, but other than that it looks great!

@kozabrada123 kozabrada123 marked this pull request as ready for review November 1, 2024 15:51
@kozabrada123 kozabrada123 merged commit 5adc0bc into dev Nov 3, 2024
9 checks passed
kozabrada123 added a commit that referenced this pull request Nov 24, 2024
Release tracker for v0.18.0 of chorus, set to release on November 24th, 2024.

## Public API changes
- #570: Various entity public api changes
- 644d3be, 85e922b: Add type `OneOrMoreSnowflakes`, allow `GatewayRequestGuildMembers` to request multiple guild and user ids
- f65b9c1: Differentiate `PresenceUpdate` and `GatewayPresenceUpdate`
- 0e5fd86: Temporarily fix `PresenceUpdate` for Spacebar Client by making `user` optional
- 61ac7d1: Updated `LazyRequest` (op 14) to use the `Snowflake` type for ids instead of just `String`

## Additions
- #564: MFA implementation, by @xystrive and @kozabrada123 
- 4ed68ce: Added [Last Messages request](https://docs.discord.sex/topics/gateway-events#request-last-messages) and [response](https://docs.discord.sex/topics/gateway-events#last-messages)
- b23fb68: Add `ReadState` to `GatewayReady`
- #571: Gateway Opcode enum
- #573: Gateway Disconnect Opcode enums

## Bugfixes

- #565: Fix sqlx En-/Decoding of `PremiumType`
- 7460d3f: Fix `GatewayIdentifyConnectionProps` for Spacebar Client by deriving default on all fields, since the client does not send it
-  3d9460f: Derive Default for `MessageReferenceType`, assume default reference_type if none is provided
- 4baecf9: Fixed a deserialization error related to `presences` in `GuildMembersChunk` being an array, not a single value
- 1b20102: Fixed a deserialization error with deserializing `activities` in `PresenceUpdate` as an empty array when they are sent as `null`
- 7feb571: Fixed a deserialization error on discord.com related to experiments (they are not implemented yet, see #578)
- fb94afa: Fixed a deserialization error on discord.com related to `last_viewed` in `ReadState` being a version / counter, not a `DateTime`

## Internal changes
- 40754c5: bump sqlx-pg-uint to v0.8.0
- #575: Refactor of gateway close code handling
- 4ed68ce: Refactored the gateway to fully use the `Opcode` enum instead of constants
- #579

---------

Co-authored-by: bitfl0wer <[email protected]>
Co-authored-by: Flori <[email protected]>
Co-authored-by: xystrive <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants