mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
voice: start update to v4, fix heartbeats
This commit is contained in:
@@ -68,7 +68,7 @@ class VoiceWebSocket extends EventEmitter {
|
|||||||
* The actual WebSocket used to connect to the Voice WebSocket Server.
|
* The actual WebSocket used to connect to the Voice WebSocket Server.
|
||||||
* @type {WebSocket}
|
* @type {WebSocket}
|
||||||
*/
|
*/
|
||||||
this.ws = WebSocket.create(`wss://${this.voiceConnection.authentication.endpoint}/`, { v: 3 });
|
this.ws = WebSocket.create(`wss://${this.voiceConnection.authentication.endpoint}/`, { v: 4 });
|
||||||
this.ws.onopen = this.onOpen.bind(this);
|
this.ws.onopen = this.onOpen.bind(this);
|
||||||
this.ws.onmessage = this.onMessage.bind(this);
|
this.ws.onmessage = this.onMessage.bind(this);
|
||||||
this.ws.onclose = this.onClose.bind(this);
|
this.ws.onclose = this.onClose.bind(this);
|
||||||
@@ -154,9 +154,10 @@ class VoiceWebSocket extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
onPacket(packet) {
|
onPacket(packet) {
|
||||||
switch (packet.op) {
|
switch (packet.op) {
|
||||||
|
case VoiceOPCodes.HELLO:
|
||||||
|
this.setHeartbeat(packet.d.heartbeat_interval);
|
||||||
|
break;
|
||||||
case VoiceOPCodes.READY:
|
case VoiceOPCodes.READY:
|
||||||
// *.75 to correct for discord devs taking longer to fix things than i do to release versions
|
|
||||||
this.setHeartbeat(packet.d.heartbeat_interval * 0.75);
|
|
||||||
/**
|
/**
|
||||||
* Emitted once the voice WebSocket receives the ready packet.
|
* Emitted once the voice WebSocket receives the ready packet.
|
||||||
* @param {Object} packet The received packet
|
* @param {Object} packet The received packet
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ exports.VoiceOPCodes = {
|
|||||||
HEARTBEAT: 3,
|
HEARTBEAT: 3,
|
||||||
SESSION_DESCRIPTION: 4,
|
SESSION_DESCRIPTION: 4,
|
||||||
SPEAKING: 5,
|
SPEAKING: 5,
|
||||||
|
HELLO: 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Events = {
|
exports.Events = {
|
||||||
|
|||||||
Reference in New Issue
Block a user