From 2bb6ecdc28df2797445c054a99e59aefb1146227 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Sun, 2 Oct 2016 15:16:54 +0100 Subject: [PATCH] documentation --- src/client/voice/VoiceWebSocket.js | 19 +++++++++++++++++++ src/client/voice/util/SecretKey.js | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/client/voice/VoiceWebSocket.js b/src/client/voice/VoiceWebSocket.js index 551941689..63346aaa9 100644 --- a/src/client/voice/VoiceWebSocket.js +++ b/src/client/voice/VoiceWebSocket.js @@ -120,11 +120,30 @@ class VoiceWebSocket extends EventEmitter { this.setHeartbeat(packet.d.heartbeat_interval); break; case Constants.VoiceOPCodes.SESSION_DESCRIPTION: + /** + * Emitted once the Voice Websocket receives a description of this voice session + * @param {string} encryptionMode the type of encryption being used + * @param {SecretKey} secretKey the secret key used for encryption + * @event VoiceWebSocket#sessionDescription + */ this.emit('sessionDescription', packet.d.mode, new SecretKey(packet.d.secret_key)); break; case Constants.VoiceOPCodes.SPEAKING: + /** + * Emitted whenever a speaking packet is received + * @param {Object} data + * @event VoiceWebSocket#speaking + */ this.emit('speaking', packet.d); break; + default: + /** + * Emitted when an unhandled packet is received + * @param {Object} packet + * @event VoiceWebSocket#unknownPacket + */ + this.emit('unknownPacket', packet); + break; } } diff --git a/src/client/voice/util/SecretKey.js b/src/client/voice/util/SecretKey.js index 50debd8c8..5e1df7a99 100644 --- a/src/client/voice/util/SecretKey.js +++ b/src/client/voice/util/SecretKey.js @@ -1,5 +1,12 @@ +/** + * Represents a Secret Key used in encryption over voice + */ class SecretKey { constructor(key) { + /** + * The key used for encryption + * @type {Uint8Array} + */ this.key = new Uint8Array(new ArrayBuffer(key.length)); for (const index in key) { this.key[index] = key[index];