Fixes disconnecting VoiceConnections before connected (#1227)

This commit is contained in:
Programmix
2017-02-25 15:17:39 -08:00
committed by Amish Shah
parent f3a7f59824
commit 275c9953a0

View File

@@ -311,11 +311,18 @@ class VoiceConnection extends EventEmitter {
*/ */
cleanup() { cleanup() {
const { ws, udp } = this.sockets; const { ws, udp } = this.sockets;
ws.removeAllListeners('error');
udp.removeAllListeners('error'); if (ws) {
ws.removeAllListeners('ready'); ws.removeAllListeners('error');
ws.removeAllListeners('sessionDescription'); ws.removeAllListeners('ready');
ws.removeAllListeners('speaking'); ws.removeAllListeners('sessionDescription');
ws.removeAllListeners('speaking');
}
if (udp) {
udp.removeAllListeners('error');
}
this.sockets.ws = null; this.sockets.ws = null;
this.sockets.udp = null; this.sockets.udp = null;
} }