voice: clean up packet handling

This commit is contained in:
Amish Shah
2018-08-16 11:28:28 +01:00
parent 64832abfdb
commit 97c34b5b6f
5 changed files with 23 additions and 29 deletions

View File

@@ -396,29 +396,25 @@ class VoiceConnection extends EventEmitter {
* @param {Object} data The received data
* @private
*/
onReady({ port, ssrc, ip, modes }) {
this.authentication.port = port;
this.authentication.ssrc = ssrc;
for (let mode of modes) {
onReady(data) {
this.authentication = data;
for (let mode of data.modes) {
if (SUPPORTED_MODES.includes(mode)) {
this.authentication.encryptionMode = mode;
this.authentication.mode = mode;
this.emit('debug', `Selecting the ${mode} mode`);
break;
}
}
this.sockets.udp.createUDPSocket(ip);
this.sockets.udp.createUDPSocket(data.ip);
}
/**
* Invoked when a session description is received.
* @param {string} mode The encryption mode
* @param {string} secret The secret key
* @param {Object} data The received data
* @private
*/
onSessionDescription(mode, secret) {
this.authentication.encryptionMode = mode;
this.authentication.secretKey = secret;
onSessionDescription(data) {
Object.assign(this.authentication, data);
this.status = VoiceStatus.CONNECTED;
clearTimeout(this.connectTimeout);
/**