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

feat(voice): support resuming voice connection #1448

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

james58899
Copy link
Contributor

https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection

The Discord voice gateway will disconnect with code 1006 after a period of time, but the UDP connection is still normal.
We can use Opcode 7 Resume to restore the websocket connection without affecting other states.
If use Opcode 0 Identify to reconnect the voice gateway will disconnect with code 4006.

@abalabahaha
Copy link
Owner

Need to test, but I think 1000 is still a normal close where reconnect isn't wanted, so === 1006 may fit better than < 4000

@james58899
Copy link
Contributor Author

In discord.js it is code === 4_015 || code < 4_0001, because discord usually uses 4014 to disconnect, but I only see 1006 in my test, so I think changing < 4000 to === 1006 is ok.

Footnotes

  1. https://github.com/discordjs/discord.js/blob/dc142c47e4021d6d37712453cc2fad6e4fe4e9f7/packages/voice/src/networking/Networking.ts#L357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants