summary refs log tree commit diff
path: root/src/webrtc/opcodes/Heartbeat.ts
blob: 932cd4583b6f96a209d6bb1deebe28ef6a9908f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import {
	CLOSECODES,
	Payload,
	Send,
	setHeartbeat,
	WebSocket,
} from "@fosscord/gateway";
import { VoiceOPCodes } from "../util";

export async function onHeartbeat(this: WebSocket, data: Payload) {
	setHeartbeat(this);
	if (isNaN(data.d)) return this.close(CLOSECODES.Decode_error);

	await Send(this, { op: VoiceOPCodes.HEARTBEAT_ACK, d: data.d });
}