Fix End Game showing false 'Connection lost' error
Add _intentionalClose flag to suppress error when server closes WebSocket after game_ended broadcast. Clean transition to lobby. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
bae5d8da3c
commit
62e7d4e1dd
@ -639,7 +639,10 @@ class GolfGame {
|
|||||||
|
|
||||||
this.ws.onclose = () => {
|
this.ws.onclose = () => {
|
||||||
console.log('Disconnected from server');
|
console.log('Disconnected from server');
|
||||||
|
if (!this._intentionalClose) {
|
||||||
this.showError('Connection lost. Please refresh the page.');
|
this.showError('Connection lost. Please refresh the page.');
|
||||||
|
}
|
||||||
|
this._intentionalClose = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ws.onerror = (error) => {
|
this.ws.onerror = (error) => {
|
||||||
@ -881,8 +884,9 @@ class GolfGame {
|
|||||||
|
|
||||||
case 'game_ended':
|
case 'game_ended':
|
||||||
// Host ended the game or player was kicked
|
// Host ended the game or player was kicked
|
||||||
this.ws.close();
|
this._intentionalClose = true;
|
||||||
this.showLobby();
|
if (this.ws) this.ws.close();
|
||||||
|
this.showScreen('lobby');
|
||||||
if (data.reason) {
|
if (data.reason) {
|
||||||
this.showError(data.reason);
|
this.showError(data.reason);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user