Add VoiceConnection.disconnect([reason]);

This commit is contained in:
Amish Shah
2016-08-23 21:47:37 +01:00
parent f9a553a7f0
commit 328f3c4ae8
6 changed files with 80 additions and 3 deletions

View File

@@ -32,6 +32,19 @@ class VoiceConnectionUDPClient extends EventEmitter {
}
}
_shutdown() {
if (this.udpSocket) {
try {
this.udpSocket.close();
} catch (err) {
if (err.message !== 'Not running') {
this.emit('error', err);
}
}
this.udpSocket = null;
}
}
connectUDP(address) {
this.udpIP = address;
this.udpSocket = udp.createSocket('udp4');
@@ -64,6 +77,10 @@ class VoiceConnectionUDPClient extends EventEmitter {
this.emit('error', { error, message });
});
this.udpSocket.on('close', error => {
this.emit('close', error);
});
const blankMessage = new Buffer(70);
blankMessage.writeUIntBE(this.data.ssrc, 0, 4);
this.send(blankMessage);