documentation

This commit is contained in:
Amish Shah
2016-10-02 15:16:54 +01:00
parent ed8b79aa46
commit 2bb6ecdc28
2 changed files with 26 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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];