From 25e4b4519838898ecdf51e65781f032a8aaa56c3 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Mon, 14 Mar 2022 10:28:05 -0700 Subject: [PATCH] Add stun/turn info after onIceCandidate Signed-off-by: James Ketrenos --- client/src/MediaControl.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/client/src/MediaControl.js b/client/src/MediaControl.js index ad5fb0f..12fefd4 100644 --- a/client/src/MediaControl.js +++ b/client/src/MediaControl.js @@ -103,10 +103,21 @@ const MediaAgent = () => { if (!event.candidate) { return; } + /* If a srflx candidate was found, notify that the STUN server works! */ + if (event.candidate.type === "srflx"){ + console.log("The STUN server is reachable!"); + console.log(` Your Public IP Address is: ${event.candidate.address}`); + } + + /* If a relay candidate was found, notify that the TURN server works! */ + if (event.candidate.type === "relay"){ + console.log("The TURN server is reachable !"); + } + sendMessage({ - type: 'relayICECandidate', + type: 'relayICECandidate', config: { - peer_id: peer_id, + peer_id: peer_id, ice_candidate: { sdpMLineIndex: event.candidate.sdpMLineIndex, candidate: event.candidate.candidate @@ -114,9 +125,9 @@ const MediaAgent = () => { } }); }; - + connection.ontrack = e => refOnTrack.current(e);; - + /* Add our local stream */ connection.addStream(stream);