Don't try to reconnect to chat forever

ipad-testing
Noah 2023-02-19 21:36:36 -08:00
parent 77a376452b
commit 03c3dd4f2e
1 changed files with 10 additions and 0 deletions

View File

@ -17,6 +17,10 @@ const app = Vue.createApp({
windowFocused: true, // browser tab is active
windowFocusedAt: new Date(),
// Disconnect spamming: don't retry too many times.
disconnectLimit: 8,
disconnectCount: 0,
// Website configuration provided by chat.html template.
config: {
channels: PublicChannels,
@ -405,6 +409,12 @@ const app = Vue.createApp({
this.ws.connected = false;
this.ChatClient(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`);
this.disconnectCount++;
if (this.disconnectCount > this.disconnectLimit) {
this.ChatClient(`It seems there's a problem connecting to the server. Please try some other time. Note that iPhones and iPads currently have issues connecting to the chat room in general.`);
return;
}
if (!this.disconnect) {
if (ev.code !== 1001) {
this.ChatClient("Reconnecting in 5s");