Don't try to reconnect to chat forever

This commit is contained in:
Noah 2023-02-19 21:36:36 -08:00
parent 77a376452b
commit 03c3dd4f2e

View File

@ -17,6 +17,10 @@ const app = Vue.createApp({
windowFocused: true, // browser tab is active windowFocused: true, // browser tab is active
windowFocusedAt: new Date(), windowFocusedAt: new Date(),
// Disconnect spamming: don't retry too many times.
disconnectLimit: 8,
disconnectCount: 0,
// Website configuration provided by chat.html template. // Website configuration provided by chat.html template.
config: { config: {
channels: PublicChannels, channels: PublicChannels,
@ -405,6 +409,12 @@ const app = Vue.createApp({
this.ws.connected = false; this.ws.connected = false;
this.ChatClient(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`); 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 (!this.disconnect) {
if (ev.code !== 1001) { if (ev.code !== 1001) {
this.ChatClient("Reconnecting in 5s"); this.ChatClient("Reconnecting in 5s");