From 629c57f890fc5124384ae83f74c9190c1db2dd4c Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Mon, 13 Jan 2020 22:29:05 +0000 Subject: [PATCH] fix: regression (changing voice servers) --- src/client/voice/VoiceConnection.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/voice/VoiceConnection.js b/src/client/voice/VoiceConnection.js index 540dd8c74..b4b1e9da1 100644 --- a/src/client/voice/VoiceConnection.js +++ b/src/client/voice/VoiceConnection.js @@ -452,8 +452,7 @@ class VoiceConnection extends EventEmitter { onSessionDescription(data) { Object.assign(this.authentication, data); this.status = VoiceStatus.CONNECTED; - const dispatcher = this.play(new SingleSilence(), { type: 'opus' }); - dispatcher.on('finish', () => { + const ready = () => { this.client.clearTimeout(this.connectTimeout); this.emit('debug', `Ready with authentication details: ${JSON.stringify(this.authentication)}`); /** @@ -462,7 +461,14 @@ class VoiceConnection extends EventEmitter { * @event VoiceConnection#ready */ this.emit('ready'); - }); + }; + if (this.dispatcher) { + ready(); + } else { + // This serves to provide support for voice receive, sending audio is required to receive it. + const dispatcher = this.play(new SingleSilence(), { type: 'opus' }); + dispatcher.once('finish', ready); + } } onStartSpeaking({ user_id, ssrc, speaking }) {