improved life check on websockets

This commit is contained in:
dcore94 2023-03-13 17:36:15 +01:00
parent 4be50cdd31
commit 69a1b7efea
3 changed files with 31 additions and 4 deletions

View File

@ -7,6 +7,7 @@ class CCPExecutionHistory extends HTMLElement {
#data = []; #data = [];
#filtered = []; #filtered = [];
#socket = null; #socket = null;
#interval = null;
#searchfield = null; #searchfield = null;
constructor(){ constructor(){
@ -240,7 +241,15 @@ class CCPExecutionHistory extends HTMLElement {
this.refreshExecution(exec.id) this.refreshExecution(exec.id)
} }
} }
window.setInterval( ()=>this.#socket.send("ping"), 30000) this.#interval = window.setInterval( ()=>{
if(this.#socket.readyState === 3){
this.#socket.close()
window.clearInterval(this.#interval)
this.connectBroadcast()
}else{
this.#socket.send("ping")
}
}, 30000)
} }
download(url, name) { download(url, name) {

View File

@ -6,6 +6,7 @@ class CCPExecutionMonitor extends HTMLElement {
#broadcasturl = null; #broadcasturl = null;
#executions = []; #executions = [];
#socket = null; #socket = null;
#interval = null;
constructor(){ constructor(){
super() super()
@ -81,7 +82,15 @@ class CCPExecutionMonitor extends HTMLElement {
this.refreshExecution(exec) this.refreshExecution(exec)
} }
} }
window.setInterval( ()=>this.#socket.send("ping"), 30000) this.#interval = window.setInterval( ()=>{
if(this.#socket.readyState === 3){
this.#socket.close()
window.clearInterval(this.#interval)
this.connectBroadcast()
}else{
this.#socket.send("ping")
}
}, 30000)
} }
download(url, name) { download(url, name) {

View File

@ -2,6 +2,7 @@ class CCPInfrastructureList extends HTMLElement{
#boot; #boot;
#socket; #socket;
#interval = null;
#infrastructures; #infrastructures;
#runtimes; #runtimes;
#rootdoc; #rootdoc;
@ -230,7 +231,15 @@ class CCPInfrastructureList extends HTMLElement{
this.#socket.onmessage = event=>{ this.#socket.onmessage = event=>{
this.fetchInfrastructures() this.fetchInfrastructures()
} }
window.setInterval( ()=>this.#socket.send("ping"), 30000) this.#interval = window.setInterval( ()=>{
if(this.#socket.readyState === 3){
this.#socket.close()
window.clearInterval(this.#interval)
this.connectBroadcast()
}else{
this.#socket.send("ping")
}
}, 30000)
} }
getCompatibleRuntimes(rts){ getCompatibleRuntimes(rts){