diff options
| author | Federico Rapetti <[email protected]> | 2023-03-04 22:38:36 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-04 15:38:36 -0600 |
| commit | 6926e39c5679e75c9ca6ef1a123abdce3d7ff992 (patch) | |
| tree | 9c095a3bcc84442414e4e1c213047c941cab40a7 | |
| parent | f7c3d87722f098ee0e3d518261a269992c5e8604 (diff) | |
| download | muse-6926e39c5679e75c9ca6ef1a123abdce3d7ff992.tar.xz muse-6926e39c5679e75c9ca6ef1a123abdce3d7ff992.zip | |
Temporary workaround for VoiceConnection stuck in signalling state (#907)
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | src/services/player.ts | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e82628..0386d30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Add temporary workaround to avoid VoiceConnection being stuck in signalling state ## [2.2.0] - 2023-02-26 ### Added diff --git a/src/services/player.ts b/src/services/player.ts index 78f72b2..0b57ad7 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -84,6 +84,22 @@ export default class { guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator as DiscordGatewayAdapterCreator, }); + + // Workaround to disable keepAlive + this.voiceConnection.on('stateChange', (oldState, newState) => { + /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */ + const oldNetworking = Reflect.get(oldState, 'networking'); + const newNetworking = Reflect.get(newState, 'networking'); + + const networkStateChangeHandler = (_: any, newNetworkState: any) => { + const newUdp = Reflect.get(newNetworkState, 'udp'); + clearInterval(newUdp?.keepAliveInterval); + }; + + oldNetworking?.off('stateChange', networkStateChangeHandler); + newNetworking?.on('stateChange', networkStateChangeHandler); + /* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */ + }); } disconnect(): void { |
