Add API-level ICE candidate exchange logging

Added logging to track when ICE candidates are sent to and received from the signaling server to help diagnose connection exchange issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-15 12:39:45 +01:00
parent 4c58dee371
commit d922329437

View File

@@ -104,7 +104,8 @@ export default function App() {
// Create connection using the manager // Create connection using the manager
const conn = client.createConnection(RTC_CONFIG); const conn = client.createConnection(RTC_CONFIG);
// Add ICE debugging // Add debugging
addApiLogging(client);
addIceLogging(conn); addIceLogging(conn);
// Setup event listeners // Setup event listeners
@@ -191,7 +192,8 @@ export default function App() {
// Create connection using the manager // Create connection using the manager
const conn = client.createConnection(RTC_CONFIG); const conn = client.createConnection(RTC_CONFIG);
// Add ICE debugging // Add debugging
addApiLogging(client);
addIceLogging(conn); addIceLogging(conn);
// Setup event listeners // Setup event listeners
@@ -254,6 +256,26 @@ export default function App() {
)); ));
}; };
// Add API-level ICE candidate logging
const addApiLogging = (client) => {
const originalAddIceCandidates = client.offers.addIceCandidates.bind(client.offers);
const originalGetIceCandidates = client.offers.getIceCandidates.bind(client.offers);
client.offers.addIceCandidates = async (offerId, candidates) => {
console.log(`📤 Sending ${candidates.length} ICE candidate(s) to server for offer ${offerId}`);
return originalAddIceCandidates(offerId, candidates);
};
client.offers.getIceCandidates = async (offerId, since) => {
const result = await originalGetIceCandidates(offerId, since);
console.log(`📥 Received ${result.length} ICE candidate(s) from server for offer ${offerId}, since=${since}`);
if (result.length > 0) {
console.log(`📥 First candidate:`, result[0]);
}
return result;
};
};
// Add ICE debugging to a connection (without overwriting existing handlers) // Add ICE debugging to a connection (without overwriting existing handlers)
const addIceLogging = (conn) => { const addIceLogging = (conn) => {
const pc = conn['pc']; // Access underlying peer connection for debugging const pc = conn['pc']; // Access underlying peer connection for debugging