@@ -312,7 +312,7 @@ class QUICConnection extends EventTarget {
312
312
*/
313
313
@ready ( new errors . ErrorQUICConnectionDestroyed ( ) , false , [ 'destroying' ] )
314
314
public async recv ( data : Uint8Array , remoteInfo : RemoteInfo ) {
315
- console . log ( 'RECV CALLED' ) ;
315
+ this . logger . debug ( 'RECV CALLED' ) ;
316
316
317
317
try {
318
318
if ( this . conn . isClosed ( ) ) {
@@ -336,7 +336,7 @@ class QUICConnection extends EventTarget {
336
336
} ,
337
337
} ;
338
338
try {
339
- // console.log(' Did a recv', data.byteLength);
339
+ this . logger . debug ( ` Did a recv ${ data . byteLength } ` ) ;
340
340
this . conn . recv ( data , recvInfo ) ;
341
341
} catch ( e ) {
342
342
// Depending on the exception, the `this.conn.recv`
@@ -382,7 +382,7 @@ class QUICConnection extends EventTarget {
382
382
}
383
383
} finally {
384
384
385
- // console.log ('RECV FINALLY');
385
+ this . logger . debug ( 'RECV FINALLY' ) ;
386
386
387
387
// Set the timeout
388
388
this . setTimeout ( ) ;
@@ -397,7 +397,7 @@ class QUICConnection extends EventTarget {
397
397
)
398
398
) {
399
399
400
- console . log ( 'CALLING DESTROY 2' ) ;
400
+ this . logger . debug ( 'CALLING DESTROY 2' ) ;
401
401
await this . destroy ( ) ;
402
402
}
403
403
}
@@ -423,7 +423,7 @@ class QUICConnection extends EventTarget {
423
423
@ready ( new errors . ErrorQUICConnectionDestroyed ( ) , false , [ 'destroying' ] )
424
424
public async send ( ) : Promise < void > {
425
425
426
- console . log ( 'SEND CALLED' ) ;
426
+ this . logger . debug ( 'SEND CALLED' ) ;
427
427
428
428
try {
429
429
if ( this . conn . isClosed ( ) ) {
@@ -439,11 +439,12 @@ class QUICConnection extends EventTarget {
439
439
let sendInfo : SendInfo ;
440
440
while ( true ) {
441
441
try {
442
- // console.log ('Did a send');
442
+ this . logger . debug ( 'Did a send' ) ;
443
443
[ sendLength , sendInfo ] = this . conn . send ( sendBuffer ) ;
444
444
} catch ( e ) {
445
+ this . logger . debug ( `SEND FAILED WITH ${ e . message } ` ) ;
445
446
if ( e . message === 'Done' ) {
446
- // console.log ('SEND IS DONE');
447
+ this . logger . debug ( 'SEND IS DONE' ) ;
447
448
return ;
448
449
}
449
450
try {
@@ -470,8 +471,7 @@ class QUICConnection extends EventTarget {
470
471
}
471
472
try {
472
473
473
- // console.log('ATTEMPTING SEND', sendBuffer, 0, sendLength, sendInfo.to.port, sendInfo.to.host);
474
- console . log ( 'SEND UDP PACKET' ) ;
474
+ this . logger . debug ( `ATTEMPTING SEND ${ sendLength } bytes to ${ sendInfo . to . port } :${ sendInfo . to . host } ` ) ;
475
475
476
476
await this . socket . send (
477
477
sendBuffer ,
@@ -481,21 +481,22 @@ class QUICConnection extends EventTarget {
481
481
sendInfo . to . host
482
482
) ;
483
483
} catch ( e ) {
484
+ console . error ( e ) ;
484
485
this . dispatchEvent ( new events . QUICConnectionErrorEvent ( { detail : e } ) ) ;
485
486
return ;
486
487
}
487
488
}
488
489
} finally {
489
490
490
- // console.log ('SEND FINALLY');
491
+ this . logger . debug ( 'SEND FINALLY' ) ;
491
492
492
493
this . setTimeout ( ) ;
493
494
if (
494
495
this [ status ] !== 'destroying' &&
495
496
( this . conn . isClosed ( ) || this . conn . isDraining ( ) )
496
497
) {
497
498
498
- console . log ( 'CALLING DESTROY' ) ;
499
+ this . logger . debug ( 'CALLING DESTROY' ) ;
499
500
500
501
await this . destroy ( ) ;
501
502
} else if (
@@ -598,55 +599,55 @@ class QUICConnection extends EventTarget {
598
599
// the time given becomes 1 second
599
600
// Why did it reduce to 1000 ms?
600
601
601
- // console.log ('Time given:', time);
602
+ // this.logger.debug ('Time given:', time);
602
603
603
- // console.log ('IS DRAINING', this.conn.isDraining());
604
+ // this.logger.debug ('IS DRAINING', this.conn.isDraining());
604
605
605
606
// Do note there is a change in one of our methods
606
607
// I think I remember, we still need to change over to that
607
608
// To enusre that exceptions mean `Done`
608
- // console.log ('PATH STATS', this.conn.pathStats());
609
+ // this.logger.debug ('PATH STATS', this.conn.pathStats());
609
610
610
611
if ( time != null ) {
611
- // console.log ('Resetting the timeout');
612
+ // this.logger.debug ('Resetting the timeout');
612
613
613
614
clearTimeout ( this . timer ) ;
614
615
this . timer = setTimeout (
615
616
async ( ) => {
616
617
617
- // console.log ('TIMEOUT HANDLER CALLED');
618
- // console.log ('draining', this.conn.isDraining());
619
- // console.log ('closed', this.conn.isClosed());
620
- // console.log ('timed out', this.conn.isTimedOut());
621
- // console.log ('established', this.conn.isEstablished());
622
- // console.log ('in early data', this.conn.isInEarlyData());
623
- // console.log ('resumed', this.conn.isResumed());
618
+ // this.logger.debug ('TIMEOUT HANDLER CALLED');
619
+ // this.logger.debug ('draining', this.conn.isDraining());
620
+ // this.logger.debug ('closed', this.conn.isClosed());
621
+ // this.logger.debug ('timed out', this.conn.isTimedOut());
622
+ // this.logger.debug ('established', this.conn.isEstablished());
623
+ // this.logger.debug ('in early data', this.conn.isInEarlyData());
624
+ // this.logger.debug ('resumed', this.conn.isResumed());
624
625
625
626
// This would only run if the `recv` and `send` is not called
626
627
// Otherwise this handler would be cleared each time and be reset
627
628
this . conn . onTimeout ( ) ;
628
629
629
- // console.log ('AFTER ON TIMEOUT');
630
+ // this.logger.debug ('AFTER ON TIMEOUT');
630
631
// DRAINING IS FALSE
631
- // console.log ('draining', this.conn.isDraining());
632
+ // this.logger.debug ('draining', this.conn.isDraining());
632
633
// CLOSED IS TRUE
633
- // console.log ('closed', this.conn.isClosed());
634
+ // this.logger.debug ('closed', this.conn.isClosed());
634
635
// TIMEDOUT IS TRUE
635
- // console.log ('timed out', this.conn.isTimedOut());
636
- // console.log ('established', this.conn.isEstablished());
637
- // console.log ('in early data', this.conn.isInEarlyData());
638
- // console.log ('resumed', this.conn.isResumed());
636
+ // this.logger.debug ('timed out', this.conn.isTimedOut());
637
+ // this.logger.debug ('established', this.conn.isEstablished());
638
+ // this.logger.debug ('in early data', this.conn.isInEarlyData());
639
+ // this.logger.debug ('resumed', this.conn.isResumed());
639
640
640
641
// Trigger a send, this will also set the timeout again at the end
641
642
642
- console . log ( 'TIMEOUT TRIGGER SEND' ) ;
643
+ this . logger . debug ( 'TIMEOUT TRIGGER SEND' ) ;
643
644
644
645
await this . send ( ) ;
645
646
} ,
646
647
time
647
648
) ;
648
649
} else {
649
- // console.log ('Clearing the timeout');
650
+ this . logger . debug ( 'Clearing the timeout' ) ;
650
651
clearTimeout ( this . timer ) ;
651
652
delete this . timer ;
652
653
if ( this . conn . isClosed ( ) || this . conn . isDraining ( ) ) {
0 commit comments