mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-25 04:54:23 +00:00
fix reconnection spamming
This commit is contained in:
@@ -155,12 +155,20 @@ createApp( {
|
|||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
if ( !self.isReconnecting ) {
|
if ( !self.isReconnecting ) {
|
||||||
self.isReconnecting = true;
|
self.isReconnecting = true;
|
||||||
self.connect();
|
self.tryReconnect();
|
||||||
self.isReconnecting = false;
|
|
||||||
}
|
}
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
}, false );
|
}, false );
|
||||||
},
|
},
|
||||||
|
tryReconnect() {
|
||||||
|
const int = setInterval( () => {
|
||||||
|
if ( !this.isReconnecting ) {
|
||||||
|
clearInterval( int );
|
||||||
|
} else {
|
||||||
|
connectToSSESource();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
|
},
|
||||||
handleBackground() {
|
handleBackground() {
|
||||||
let colourDetails = [];
|
let colourDetails = [];
|
||||||
let colours = [];
|
let colours = [];
|
||||||
|
|||||||
@@ -128,12 +128,20 @@ createApp( {
|
|||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
if ( !self.isReconnecting ) {
|
if ( !self.isReconnecting ) {
|
||||||
self.isReconnecting = true;
|
self.isReconnecting = true;
|
||||||
self.connect();
|
self.tryReconnect();
|
||||||
self.isReconnecting = false;
|
|
||||||
}
|
}
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
}, false );
|
}, false );
|
||||||
},
|
},
|
||||||
|
tryReconnect() {
|
||||||
|
const int = setInterval( () => {
|
||||||
|
if ( !this.isReconnecting ) {
|
||||||
|
clearInterval( int );
|
||||||
|
} else {
|
||||||
|
connectToSSESource();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.connect();
|
this.connect();
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ const connectToSSESource = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
source.onopen = () => {
|
source.onopen = () => {
|
||||||
|
isReconnecting = false;
|
||||||
console.log( '[ BACKEND INTEGRATION ] Connection to notifier successful' );
|
console.log( '[ BACKEND INTEGRATION ] Connection to notifier successful' );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -86,13 +87,9 @@ const connectToSSESource = () => {
|
|||||||
|
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
if ( !isReconnecting ) {
|
if ( !isReconnecting ) {
|
||||||
if ( errorCount > 5 ) {
|
|
||||||
isSSEAuth = false;
|
|
||||||
}
|
|
||||||
isReconnecting = true;
|
isReconnecting = true;
|
||||||
console.log( '[ BACKEND INTEGRATION ] Disconnected from notifier, reconnecting...' );
|
console.log( '[ BACKEND INTEGRATION ] Disconnected from notifier, reconnecting...' );
|
||||||
connectToSSESource();
|
tryReconnect();
|
||||||
isReconnecting = false;
|
|
||||||
}
|
}
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
}, false );
|
}, false );
|
||||||
@@ -109,6 +106,22 @@ const connectToSSESource = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tryReconnect = () => {
|
||||||
|
const int = setInterval( () => {
|
||||||
|
if ( !isReconnecting ) {
|
||||||
|
clearInterval( int );
|
||||||
|
} else {
|
||||||
|
if ( errorCount > 5 ) {
|
||||||
|
isSSEAuth = false;
|
||||||
|
errorCount = 0;
|
||||||
|
} else {
|
||||||
|
errorCount += 1;
|
||||||
|
}
|
||||||
|
connectToSSESource();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
let authKey = conf.authKey ?? '';
|
let authKey = conf.authKey ?? '';
|
||||||
|
|
||||||
connect();
|
connect();
|
||||||
|
|||||||
@@ -656,12 +656,20 @@ const app = Vue.createApp( {
|
|||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
if ( !self.isReconnecting ) {
|
if ( !self.isReconnecting ) {
|
||||||
self.isReconnecting = true;
|
self.isReconnecting = true;
|
||||||
self.connect();
|
self.tryReconnect();
|
||||||
self.isReconnecting = false;
|
|
||||||
}
|
}
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
}, false );
|
}, false );
|
||||||
},
|
},
|
||||||
|
tryReconnect() {
|
||||||
|
const int = setInterval( () => {
|
||||||
|
if ( !this.isReconnecting ) {
|
||||||
|
clearInterval( int );
|
||||||
|
} else {
|
||||||
|
connectToSSESource();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
|
},
|
||||||
dismissNotification() {
|
dismissNotification() {
|
||||||
this.isShowingWarning = false;
|
this.isShowingWarning = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,12 +154,20 @@ createApp( {
|
|||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
if ( !self.isReconnecting ) {
|
if ( !self.isReconnecting ) {
|
||||||
self.isReconnecting = true;
|
self.isReconnecting = true;
|
||||||
self.connect();
|
self.tryReconnect();
|
||||||
self.isReconnecting = false;
|
|
||||||
}
|
}
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
}, false );
|
}, false );
|
||||||
},
|
},
|
||||||
|
tryReconnect() {
|
||||||
|
const int = setInterval( () => {
|
||||||
|
if ( !this.isReconnecting ) {
|
||||||
|
clearInterval( int );
|
||||||
|
} else {
|
||||||
|
connectToSSESource();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
|
},
|
||||||
handleBackground() {
|
handleBackground() {
|
||||||
let colourDetails = [];
|
let colourDetails = [];
|
||||||
let colours = [];
|
let colours = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user