From 1ac1121793a706860c9aa3d4b31667f37a6ea1a0 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sat, 15 Nov 2025 13:31:21 +0100 Subject: [PATCH] Fix ICE candidate handling by using addEventListener MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed from overwriting onicecandidate handlers (which broke the 'this' context) to using addEventListener. This ensures the connection manager's handlers can properly send ICE candidates without context issues. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/App.jsx | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index ec8de60..7f02157 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -288,18 +288,12 @@ export default function App() { }; }; - // Add ICE debugging to a connection (without overwriting existing handlers) + // Add ICE debugging to a connection const addIceLogging = (conn) => { const pc = conn['pc']; // Access underlying peer connection for debugging if (pc) { - // Store original handlers - const originalIceCandidate = pc.onicecandidate; - const originalGatheringStateChange = pc.onicegatheringstatechange; - const originalIceConnectionStateChange = pc.oniceconnectionstatechange; - const originalConnectionStateChange = pc.onconnectionstatechange; - - // Wrap handlers to add logging - pc.onicecandidate = (event) => { + // Add new handlers that don't override existing ones + pc.addEventListener('icecandidate', (event) => { if (event.candidate) { console.log('🧊 ICE candidate gathered:', { type: event.candidate.type, @@ -311,24 +305,19 @@ export default function App() { } else { console.log('🧊 ICE gathering complete'); } - // Call original handler - if (originalIceCandidate) originalIceCandidate.call(pc, event); - }; + }); - pc.onicegatheringstatechange = (event) => { + pc.addEventListener('icegatheringstatechange', () => { console.log('🧊 ICE gathering state:', pc.iceGatheringState); - if (originalGatheringStateChange) originalGatheringStateChange.call(pc, event); - }; + }); - pc.oniceconnectionstatechange = (event) => { + pc.addEventListener('iceconnectionstatechange', () => { console.log('🧊 ICE connection state:', pc.iceConnectionState); - if (originalIceConnectionStateChange) originalIceConnectionStateChange.call(pc, event); - }; + }); - pc.onconnectionstatechange = (event) => { + pc.addEventListener('connectionstatechange', () => { console.log('🔌 Connection state:', pc.connectionState); - if (originalConnectionStateChange) originalConnectionStateChange.call(pc, event); - }; + }); } };