summary refs log tree commit diff
path: root/src/webrtc/events/Connection.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/webrtc/events/Connection.ts')
-rw-r--r--src/webrtc/events/Connection.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/webrtc/events/Connection.ts b/src/webrtc/events/Connection.ts
index bf228d64..9300b6b2 100644
--- a/src/webrtc/events/Connection.ts
+++ b/src/webrtc/events/Connection.ts
@@ -14,7 +14,11 @@ try {
 // TODO: specify rate limit in config
 // TODO: check msg max size
 
-export async function Connection(this: WS.Server, socket: WebSocket, request: IncomingMessage) {
+export async function Connection(
+	this: WS.Server,
+	socket: WebSocket,
+	request: IncomingMessage,
+) {
 	try {
 		socket.on("close", onClose.bind(socket));
 		socket.on("message", onMessage.bind(socket));
@@ -29,7 +33,7 @@ export async function Connection(this: WS.Server, socket: WebSocket, request: In
 				"open",
 				"ping",
 				"pong",
-				"unexpected-response"
+				"unexpected-response",
 			].forEach((x) => {
 				socket.on(x, (y) => console.log("[WebRTC]", x, y));
 			});
@@ -39,7 +43,8 @@ export async function Connection(this: WS.Server, socket: WebSocket, request: In
 
 		socket.encoding = "json";
 		socket.version = Number(searchParams.get("v")) || 5;
-		if (socket.version < 3) return socket.close(CLOSECODES.Unknown_error, "invalid version");
+		if (socket.version < 3)
+			return socket.close(CLOSECODES.Unknown_error, "invalid version");
 
 		setHeartbeat(socket);
 
@@ -50,11 +55,11 @@ export async function Connection(this: WS.Server, socket: WebSocket, request: In
 		await Send(socket, {
 			op: VoiceOPCodes.HELLO,
 			d: {
-				heartbeat_interval: 1000 * 30
-			}
+				heartbeat_interval: 1000 * 30,
+			},
 		});
 	} catch (error) {
 		console.error("[WebRTC]", error);
 		return socket.close(CLOSECODES.Unknown_error);
 	}
-}
\ No newline at end of file
+}