1
0

Add stun/turn info after onIceCandidate

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-03-14 10:28:05 -07:00
parent a4bc4b4d3b
commit 25e4b45198

View File

@ -103,10 +103,21 @@ const MediaAgent = () => {
if (!event.candidate) { if (!event.candidate) {
return; 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({ sendMessage({
type: 'relayICECandidate', type: 'relayICECandidate',
config: { config: {
peer_id: peer_id, peer_id: peer_id,
ice_candidate: { ice_candidate: {
sdpMLineIndex: event.candidate.sdpMLineIndex, sdpMLineIndex: event.candidate.sdpMLineIndex,
candidate: event.candidate.candidate candidate: event.candidate.candidate
@ -114,9 +125,9 @@ const MediaAgent = () => {
} }
}); });
}; };
connection.ontrack = e => refOnTrack.current(e);; connection.ontrack = e => refOnTrack.current(e);;
/* Add our local stream */ /* Add our local stream */
connection.addStream(stream); connection.addStream(stream);