mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
VoiceConnection rework (#1183)
* VoiceConnection rework - improves codebase - removes concept of pending connections - attempts to fix memory leaks by removing EventEmitter listeners - makes voice connections keep track of its own channel when it is moved by another user - allows voice connections to reconnect when Discord falls back to another voice server or a region change occurs - adds events for some of the aforementioned events * Removed unused code * More clean up / bugfixes * Added typedefs to Status and VoiceStatus constants
This commit is contained in:
@@ -91,6 +91,30 @@ class VoiceReceiver extends EventEmitter {
|
||||
this.destroyed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when a user stops speaking
|
||||
* @param {User} user The user that stopped speaking
|
||||
* @private
|
||||
*/
|
||||
stoppedSpeaking(user) {
|
||||
const opusStream = this.opusStreams.get(user.id);
|
||||
const pcmStream = this.pcmStreams.get(user.id);
|
||||
const opusEncoder = this.opusEncoders.get(user.id);
|
||||
if (opusStream) {
|
||||
opusStream.push(null);
|
||||
opusStream.open = false;
|
||||
this.opusStreams.delete(user.id);
|
||||
}
|
||||
if (pcmStream) {
|
||||
pcmStream.push(null);
|
||||
pcmStream.open = false;
|
||||
this.pcmStreams.delete(user.id);
|
||||
}
|
||||
if (opusEncoder) {
|
||||
opusEncoder.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a readable stream for a user that provides opus data while the user is speaking. When the user
|
||||
* stops speaking, the stream is destroyed.
|
||||
|
||||
Reference in New Issue
Block a user