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:
2025-12-10 19:51:54 +01:00
parent a6329c8708
commit db651d4193

View File

@@ -253,9 +253,13 @@ 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) {
console.log(`[Host Polling] Processing ${answererCandidates.length} answerer ICE candidate(s) for offer ${offerId}`);
for (const item of answererCandidates) {
if (item.candidate) { if (item.candidate) {
try { try {
await pc.addIceCandidate(new RTCIceCandidate(item.candidate)); await pc.addIceCandidate(new RTCIceCandidate(item.candidate));
@@ -269,9 +273,10 @@ 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);