summary refs log tree commit diff
path: root/webrtc/src/opcodes/Identify.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/src/opcodes/Identify.ts')
-rw-r--r--webrtc/src/opcodes/Identify.ts37
1 files changed, 31 insertions, 6 deletions
diff --git a/webrtc/src/opcodes/Identify.ts b/webrtc/src/opcodes/Identify.ts
index e965e3de..d7da5c7c 100644
--- a/webrtc/src/opcodes/Identify.ts
+++ b/webrtc/src/opcodes/Identify.ts
@@ -28,12 +28,12 @@ export async function onIdentify(this: Server, socket: WebSocket, data: Identify
 		}
 	);
 	const user = session.user;
-	const guild = await Guild.findOneOrFail({ id: data.d.server_id });
+	const guild = await Guild.findOneOrFail({ id: data.d.server_id }, { relations: ["members"] });
 
 	if (!guild.members.find(x => x.id === user.id))
 		return socket.close(CLOSECODES.Invalid_intent);
 
-	var transport = await this.mediasoupRouters[0].createWebRtcTransport({
+	var transport = this.mediasoupTransports[0] || await this.mediasoupRouters[0].createWebRtcTransport({
 		listenIps: [{ ip: "0.0.0.0", announcedIp: "127.0.0.1" }],
 		enableUdp: true,
 		enableTcp: true,
@@ -66,13 +66,39 @@ export async function onIdentify(this: Server, socket: WebSocket, data: Identify
 		}
 	*/
 
+
+
+	/* 
+		{
+			"streams": [
+				{ "type": "video", "ssrc": 129861, "rtx_ssrc": 129862, "rid": "100", "quality": 100, "active": false }
+			],
+			"ssrc": 129860,
+			"port": 50003,
+			"modes": [
+				"aead_aes256_gcm_rtpsize",
+				"aead_aes256_gcm",
+				"xsalsa20_poly1305_lite_rtpsize",
+				"xsalsa20_poly1305_lite",
+				"xsalsa20_poly1305_suffix",
+				"xsalsa20_poly1305"
+			],
+			"ip": "109.200.213.251",
+			"experiments": [
+				"bwe_conservative_link_estimate",
+				"bwe_remote_locus_client",
+				"fixed_keyframe_interval"
+			];
+		};
+	*/
+
 	socket.send(JSON.stringify({
 		op: VoiceOPCodes.READY,
 		d: {
-			streams: [...data.d.streams.map(x => ({ ...x, rtx_ssrc: 1311886, ssrc: 1311885, active: false, }))],
-			ssrc: 1,
+			streams: [...data.d.streams.map(x => ({ ...x, rtx_ssrc: Math.floor(Math.random() * 10000), ssrc: Math.floor(Math.random() * 10000), active: false, }))],
+			ssrc: Math.floor(Math.random() * 10000),
 			ip: transport.iceCandidates[0].ip,
-			port: transport.iceCandidates[0].port,
+			port: "50001",
 			modes: [
 				"aead_aes256_gcm_rtpsize",
 				"aead_aes256_gcm",
@@ -81,7 +107,6 @@ export async function onIdentify(this: Server, socket: WebSocket, data: Identify
 				"xsalsa20_poly1305_suffix",
 				"xsalsa20_poly1305"
 			],
-			heartbeat_interval: 1,
 			experiments: [],
 		},
 	}));