@@ -97,10 +97,10 @@ export class Socket extends EventSpewer {
97
97
this . videoEnabled = ! ! options . video ;
98
98
99
99
if ( options . forceMode !== undefined ) {
100
- if ( ! MEDIA_ENCRYPTION_MODES . includes ( options . forceMode ) ) {
100
+ if ( ! MEDIA_ENCRYPTION_MODES . includes ( options . forceMode as MediaEncryptionModes ) ) {
101
101
throw new Error ( 'Unknown Encryption Mode' ) ;
102
102
}
103
- this . forceMode = < MediaEncryptionModes > options . forceMode ;
103
+ this . forceMode = options . forceMode as MediaEncryptionModes ;
104
104
}
105
105
106
106
Object . defineProperties ( this , {
@@ -249,12 +249,10 @@ export class Socket extends EventSpewer {
249
249
250
250
// unresumable events
251
251
// 1000 Normal Disconnected
252
- // 1001 Going Away
253
252
// 4014 Voice Channel Kick/Deleted
254
253
// 4015 Voice Server Crashed
255
254
switch ( code ) {
256
255
case SocketCloseCodes . NORMAL :
257
- case SocketCloseCodes . GOING_AWAY :
258
256
case SocketMediaCloseCodes . DISCONNECTED :
259
257
case SocketMediaCloseCodes . VOICE_SERVER_CRASHED : {
260
258
this . identified = false ;
@@ -626,25 +624,26 @@ export class Socket extends EventSpewer {
626
624
}
627
625
628
626
if ( this . protocol === MediaProtocols . UDP ) {
629
- let mode : null | string = null ;
627
+ let mode : null | MediaEncryptionModes = null ;
630
628
if ( this . forceMode && MEDIA_ENCRYPTION_MODES . includes ( this . forceMode ) ) {
631
629
mode = this . forceMode ;
632
- }
633
- if ( mode === null ) {
634
- for ( let m of data . modes ) {
630
+ } else {
631
+ for ( let value of data . modes ) {
632
+ let m = value as MediaEncryptionModes ;
635
633
if ( MEDIA_ENCRYPTION_MODES . includes ( m ) ) {
636
634
mode = m ;
637
635
break ;
638
636
}
639
637
}
640
638
}
639
+ let transport = this . transport as MediaUDPSocket ;
641
640
if ( mode ) {
642
- ( < MediaUDPSocket > this . transport ) . setMode ( mode ) ;
643
- ( < MediaUDPSocket > this . transport ) . setSSRC ( data . ssrc ) ;
644
- ( < MediaUDPSocket > this . transport ) . connect ( data . ip , data . port ) ;
645
- this . emit ( SocketEvents . TRANSPORT , this . transport ) ;
641
+ transport . setMode ( mode ) ;
642
+ transport . setSSRC ( data . ssrc ) ;
643
+ transport . connect ( data . ip , data . port ) ;
644
+ this . emit ( SocketEvents . TRANSPORT , transport ) ;
646
645
} else {
647
- ( < MediaUDPSocket > this . transport ) . disconnect ( ) ;
646
+ transport . disconnect ( ) ;
648
647
this . transport = null ;
649
648
this . emit ( SocketEvents . WARN , new Error ( `No supported voice mode found in ${ JSON . stringify ( data . modes ) } ` ) ) ;
650
649
}
0 commit comments