delay connectBroadcast in order to ensure subject

This commit is contained in:
dcore94 2023-06-26 20:11:40 +02:00
parent de1179c515
commit fb74d21d4b
1 changed files with 10 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class CCPExecutionHistory extends HTMLElement {
} }
connectedCallback(){ connectedCallback(){
this.connectBroadcast() this.connectBroadcastWithSubject()
this.render() this.render()
this.refreshExecutions() this.refreshExecutions()
} }
@ -272,6 +272,15 @@ class CCPExecutionHistory extends HTMLElement {
}) })
} }
connectBroadcastWithSubject(){
var interval = window.setInterval( ()=>{
if(this.#boot.subject){
window.clearInterval(interval)
this.connectBroadcast()
}
}, 1000)
}
connectBroadcast(){ connectBroadcast(){
this.#socket = new WebSocket(`${this.#broadcasturl}/unified?subject=${this.#boot.subject}`); this.#socket = new WebSocket(`${this.#broadcasturl}/unified?subject=${this.#boot.subject}`);
this.#socket.onmessage = event=>{ this.#socket.onmessage = event=>{