summary refs log tree commit diff
path: root/webrtc/src/opcodes/Heartbeat.ts
blob: 1b6c5bcdabe9c6ee546357ad2d4afae7961c3565 (plain) (blame)
1
2
3
4
5
6
7
8
9
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 });
}