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

@@ -168,15 +168,13 @@ class VoiceWebSocket extends EventEmitter {
break;
/* eslint-disable no-case-declarations */
case VoiceOPCodes.SESSION_DESCRIPTION:
const key = new Uint8Array(new ArrayBuffer(packet.d.secret_key.length));
for (const i in packet.d.secret_key) key[i] = packet.d.secret_key[i];
packet.d.secret_key = new Uint8Array(packet.d.secret_key);
/**
* Emitted once the Voice Websocket receives a description of this voice session.
* @param {string} encryptionMode The type of encryption being used
* @param {Uint8Array} secretKey The secret key used for encryption
* @param {Object} packet The received packet
* @event VoiceWebSocket#sessionDescription
*/
this.emit('sessionDescription', packet.d.mode, key);
this.emit('sessionDescription', packet.d);
break;
case VoiceOPCodes.CLIENT_CONNECT:
this.connection.ssrcMap.set(+packet.d.audio_ssrc, packet.d.user_id);