Spaces:
Running
Running
Update index.html
Browse files- index.html +13 -12
index.html
CHANGED
@@ -357,19 +357,20 @@
|
|
357 |
const offer = await peerConnection.createOffer();
|
358 |
await peerConnection.setLocalDescription(offer);
|
359 |
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
-
|
370 |
-
peerConnection.addEventListener("icegatheringstatechange", checkState);
|
371 |
-
}
|
372 |
-
});
|
373 |
|
374 |
peerConnection.addEventListener('connectionstatechange', () => {
|
375 |
console.log('connectionstatechange', peerConnection.connectionState);
|
|
|
357 |
const offer = await peerConnection.createOffer();
|
358 |
await peerConnection.setLocalDescription(offer);
|
359 |
|
360 |
+
peerConnection.onicecandidate = ({ candidate }) => {
|
361 |
+
if (candidate) {
|
362 |
+
console.debug("Sending ICE candidate", candidate);
|
363 |
+
fetch('/webrtc/offer', {
|
364 |
+
method: 'POST',
|
365 |
+
headers: { 'Content-Type': 'application/json' },
|
366 |
+
body: JSON.stringify({
|
367 |
+
candidate: candidate.toJSON(),
|
368 |
+
webrtc_id: webrtc_id,
|
369 |
+
type: "ice-candidate",
|
370 |
+
})
|
371 |
+
})
|
372 |
}
|
373 |
+
};
|
|
|
|
|
|
|
374 |
|
375 |
peerConnection.addEventListener('connectionstatechange', () => {
|
376 |
console.log('connectionstatechange', peerConnection.connectionState);
|