mirror of
https://github.com/xtr-dev/rondevu-demo.git
synced 2025-12-16 04:53:24 +00:00
Filter ICE candidates by role in offerer polling
- Offerer now filters for answerer ICE candidates only - Ignores own candidates returned from server - Uses role field to distinguish between offerer and answerer candidates - Improves logging to show answerer candidate count
This commit is contained in:
27
src/App.jsx
27
src/App.jsx
@@ -253,17 +253,22 @@ export default function App() {
|
|||||||
const pc = offerIdToPeerConnection[offerId];
|
const pc = offerIdToPeerConnection[offerId];
|
||||||
|
|
||||||
if (pc && candidates.length > 0) {
|
if (pc && candidates.length > 0) {
|
||||||
console.log(`[Host Polling] Processing ${candidates.length} ICE candidate(s) for offer ${offerId}`);
|
// Filter for answerer candidates only (offerer doesn't need their own candidates back)
|
||||||
|
const answererCandidates = candidates.filter(item => item.role === 'answerer');
|
||||||
|
|
||||||
for (const item of candidates) {
|
if (answererCandidates.length > 0) {
|
||||||
if (item.candidate) {
|
console.log(`[Host Polling] Processing ${answererCandidates.length} answerer ICE candidate(s) for offer ${offerId}`);
|
||||||
try {
|
|
||||||
await pc.addIceCandidate(new RTCIceCandidate(item.candidate));
|
for (const item of answererCandidates) {
|
||||||
totalIceCandidates++;
|
if (item.candidate) {
|
||||||
// Update timestamp
|
try {
|
||||||
setLastAnswerTimestamp(prev => Math.max(prev, item.createdAt));
|
await pc.addIceCandidate(new RTCIceCandidate(item.candidate));
|
||||||
} catch (err) {
|
totalIceCandidates++;
|
||||||
console.warn(`[Host Polling] Failed to add ICE candidate for offer ${offerId}:`, err);
|
// Update timestamp
|
||||||
|
setLastAnswerTimestamp(prev => Math.max(prev, item.createdAt));
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(`[Host Polling] Failed to add ICE candidate for offer ${offerId}:`, err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,7 +276,7 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (totalIceCandidates > 0) {
|
if (totalIceCandidates > 0) {
|
||||||
console.log(`✅ [Host Polling] Added ${totalIceCandidates} ICE candidate(s)`);
|
console.log(`✅ [Host Polling] Added ${totalIceCandidates} answerer ICE candidate(s)`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[Host Polling] Error polling:', err);
|
console.error('[Host Polling] Error polling:', err);
|
||||||
|
|||||||
Reference in New Issue
Block a user