Alert on websocket close

This commit is contained in:
Ruben van de Ven 2022-03-25 09:32:37 +01:00
parent 1e1cb5cfd0
commit 949a16b01f

View file

@ -119,7 +119,7 @@ class Canvas {
this.setColor(this.colors[0]); this.setColor(this.colors[0]);
this.socket = new WebSocket(this.url); this.socket = new WebSocket(this.url); // TODO: reconnectingwebsocket
this.socket.addEventListener('open', (e) => { this.socket.addEventListener('open', (e) => {
this.sendDimensions(); this.sendDimensions();
@ -150,6 +150,10 @@ class Canvas {
// this.openTheFloor() // this.openTheFloor()
} }
}); });
this.socket.addEventListener('close', (e) => {
this.closeTheFloor();
alert('Internet connection seems to have problems. Please reload the page to reconnect.');
});
} }
setPreloaded(json_url) { setPreloaded(json_url) {
@ -207,6 +211,10 @@ class Canvas {
this.wrapperEl.classList.remove('closed'); this.wrapperEl.classList.remove('closed');
} }
closeTheFloor() {
this.wrapperEl.classList.add('closed');
}
setFilename(filename) { setFilename(filename) {
this.filename = filename; this.filename = filename;
this.filenameEl.innerText = filename; this.filenameEl.innerText = filename;