From aa8a9eea6b5475d949ee9124a3f47d8166d019fc Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Mon, 7 Mar 2022 19:15:33 +1100 Subject: augh --- webrtc/src/util/Heartbeat.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'webrtc/src/util') diff --git a/webrtc/src/util/Heartbeat.ts b/webrtc/src/util/Heartbeat.ts index 7b5ed9cd..8c5e3a7a 100644 --- a/webrtc/src/util/Heartbeat.ts +++ b/webrtc/src/util/Heartbeat.ts @@ -1,18 +1,23 @@ import { WebSocket, CLOSECODES } from "@fosscord/gateway"; import { VoiceOPCodes } from "@fosscord/util"; -export async function setHeartbeat(socket: WebSocket) { +export async function setHeartbeat(socket: WebSocket, nonce?: Number) { if (socket.heartbeatTimeout) clearTimeout(socket.heartbeatTimeout); socket.heartbeatTimeout = setTimeout(() => { return socket.close(CLOSECODES.Session_timed_out); }, 1000 * 45); - socket.send(JSON.stringify({ - op: VoiceOPCodes.HEARTBEAT_ACK, - d: { - v: 6, - heartbeat_interval: 13750, - } - })); + if (!nonce) { + socket.send(JSON.stringify({ + op: VoiceOPCodes.HELLO, + d: { + v: 5, + heartbeat_interval: 13750, + } + })); + } + else { + socket.send(JSON.stringify({ op: VoiceOPCodes.HEARTBEAT_ACK, d: nonce })); + } } \ No newline at end of file -- cgit 1.5.1