@@ -19,10 +19,6 @@ export class WebRTCClient {
1919 }
2020
2121 async connect ( deviceId , authToken , rtcToken ) {
22- console . log ( "Connecting WebRTC client with deviceId:" , deviceId )
23- console . log ( "Using authToken:" , authToken )
24- console . log ( "Using rtcToken:" , rtcToken )
25-
2622 if ( ! authToken ) {
2723 throw new Error ( "Authentication token is required to connect." )
2824 }
@@ -37,49 +33,27 @@ export class WebRTCClient {
3733 this . peerConnection = new RTCPeerConnection ( {
3834 iceServers : this . iceServers
3935 } )
40- console . log ( "Created RTCPeerConnection with config:" , {
41- iceServers : this . iceServers
42- } )
43-
44- console . log ( "Created RTCPeerConnection:" , this . peerConnection )
4536
4637 // --- MODIFICATION: Queue ICE candidates instead of sending immediately ---
4738 this . peerConnection . onicecandidate = ( event ) => {
4839 if ( event . candidate ) {
49- console . log (
50- "ICE Candidate Found, queueing:" ,
51- event . candidate
52- )
5340 this . iceCandidateQueue . push ( event . candidate )
54- } else {
55- console . log ( "All ICE candidates have been gathered." )
5641 }
5742 }
5843
5944 this . peerConnection . oniceconnectionstatechange = ( event ) => {
6045 const state = this . peerConnection . iceConnectionState
61- console . log (
62- `%cICE Connection State Change: ${ state } ` ,
63- "font-weight: bold; color: blue;"
64- )
6546 }
6647
6748 this . peerConnection . onconnectionstatechange = ( event ) => {
6849 const state = this . peerConnection . connectionState
69- console . log (
70- `%cPeer Connection State Change: ${ state } ` ,
71- "font-weight: bold; color: green;"
72- )
7350
7451 // --- START MODIFICATION: Handle temporary disconnections ---
7552 // If connection is established or re-established, clear any pending disconnect timer.
7653 if ( state === "connected" ) {
7754 if ( this . disconnectTimer ) {
7855 clearTimeout ( this . disconnectTimer )
7956 this . disconnectTimer = null
80- console . log (
81- "WebRTC reconnected. Disconnect timer cleared."
82- )
8357 }
8458 this . options . onConnected ?. ( )
8559 }
@@ -113,13 +87,6 @@ export class WebRTCClient {
11387 // --- END MODIFICATION ---
11488 }
11589
116- this . peerConnection . ondatachannel = ( event ) => {
117- console . log (
118- "Data Channel established by remote peer:" ,
119- event . channel
120- )
121- }
122-
12390 const audioConstraints = {
12491 ...( deviceId && { deviceId : { exact : deviceId } } ) ,
12592 noiseSuppression : false ,
@@ -130,7 +97,6 @@ export class WebRTCClient {
13097 } )
13198
13299 this . setupAudioAnalysis ( )
133- console . log ( "Acquired media stream:" , this . mediaStream )
134100
135101 this . mediaStream . getTracks ( ) . forEach ( ( track ) => {
136102 if ( this . peerConnection ) {
@@ -139,7 +105,6 @@ export class WebRTCClient {
139105 } )
140106
141107 this . peerConnection . addEventListener ( "track" , ( event ) => {
142- console . log ( "Received track event:" , event )
143108 this . options . onAudioStream ?. ( event . streams [ 0 ] )
144109 } )
145110
@@ -181,13 +146,9 @@ export class WebRTCClient {
181146 }
182147
183148 const serverResponse = await response . json ( )
184- console . log ( "Received server answer:" , serverResponse )
185149 await this . peerConnection . setRemoteDescription ( serverResponse )
186150
187151 // --- MODIFICATION: Send all queued ICE candidates now ---
188- console . log (
189- `Sending ${ this . iceCandidateQueue . length } queued ICE candidates...`
190- )
191152 for ( const candidate of this . iceCandidateQueue ) {
192153 fetch ( `${ this . serverUrl } /voice/webrtc/offer` , {
193154 method : "POST" ,
@@ -207,9 +168,6 @@ export class WebRTCClient {
207168 }
208169 this . iceCandidateQueue = [ ] // Clear the queue
209170
210- console . log (
211- "WebRTC signaling complete. Waiting for connection to establish..."
212- )
213171 } catch ( error ) {
214172 console . error ( "Error connecting WebRTC:" , error )
215173 this . disconnect ( )
@@ -277,10 +235,6 @@ export class WebRTCClient {
277235 }
278236
279237 disconnect ( ) {
280- // --- NEW: Add a log here for clarity on manual disconnects ---
281- console . log ( "Disconnect called. Cleaning up WebRTC resources." )
282- // --- END NEW ---
283-
284238 if ( this . disconnectTimer ) {
285239 clearTimeout ( this . disconnectTimer )
286240 this . disconnectTimer = null
0 commit comments