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 = [];
#filtered = [];
#socket = null;
#interval = null;
#searchfield = null;
constructor(){
@ -239,8 +240,16 @@ class CCPExecutionHistory extends HTMLElement {
if(exec){
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) {

View File

@ -6,6 +6,7 @@ class CCPExecutionMonitor extends HTMLElement {
#broadcasturl = null;
#executions = [];
#socket = null;
#interval = null;
constructor(){
super()
@ -81,7 +82,15 @@ class CCPExecutionMonitor extends HTMLElement {
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) {

View File

@ -2,6 +2,7 @@ class CCPInfrastructureList extends HTMLElement{
#boot;
#socket;
#interval = null;
#infrastructures;
#runtimes;
#rootdoc;
@ -230,7 +231,15 @@ class CCPInfrastructureList extends HTMLElement{
this.#socket.onmessage = event=>{
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){