@@ -13,7 +13,7 @@ export default class CommsManager {
1313 private ws : WebSocket ;
1414 private observers : { [ id : string ] : Function [ ] } = { } ;
1515 private pendingPromises : Map < string , PromiseHandlers > = new Map ( ) ;
16- private static timeoutId ?: number ;
16+ private timeoutId ?: number ;
1717 private static state : string = "idle" ;
1818 private static adress : string = "ws://127.0.0.1:7163" ;
1919 private static universe ?: string ;
@@ -74,7 +74,7 @@ export default class CommsManager {
7474 console . log ( `Connection with ${ CommsManager . adress } interrupted` ) ;
7575 }
7676
77- CommsManager . timeoutId = window . setTimeout ( function ( ) {
77+ this . timeoutId = window . setTimeout ( function ( ) {
7878 delete CommsManager . instance ;
7979 CommsManager . instance = new CommsManager ( ) ;
8080 } , 1000 ) ;
@@ -92,12 +92,11 @@ export default class CommsManager {
9292
9393 public static deleteInstance ( ) {
9494 if ( CommsManager . instance ) {
95+ if ( CommsManager . instance . timeoutId ) {
96+ window . clearTimeout ( CommsManager . instance . timeoutId ) ;
97+ }
9598 delete CommsManager . instance ;
9699 CommsManager . instance = undefined ;
97- if ( CommsManager . timeoutId ) {
98- window . clearTimeout ( CommsManager . timeoutId ) ;
99- CommsManager . timeoutId = undefined ;
100- }
101100 }
102101 }
103102
0 commit comments