mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-02 00:13:28 +00:00
[BugFix] Join Lobby Bugfix (#2947)
## Description: If a WebSocket was "connecting", but the user un-clicks the lobby in that time, it doesn't remove them from the lobby, and they would still be put into the game. @evanpelle needed for v29 imo. It also fixes an issue where it wouldn't update your URL back to the home url when unclicking the lobby (websocket issue or not). This is a hotfix to fix that. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n
This commit is contained in:
@@ -868,6 +868,12 @@ class Client {
|
||||
this.gameStop();
|
||||
this.gameStop = null;
|
||||
|
||||
try {
|
||||
history.replaceState(null, "", "/");
|
||||
} catch (e) {
|
||||
console.warn("Failed to restore URL on leave:", e);
|
||||
}
|
||||
|
||||
document.body.classList.remove("in-game");
|
||||
|
||||
crazyGamesSDK.gameplayStop();
|
||||
|
||||
+11
-3
@@ -725,10 +725,18 @@ export class Transport {
|
||||
this.socket.onclose = null;
|
||||
this.socket.onerror = null;
|
||||
|
||||
// Close the connection if it's still open
|
||||
if (this.socket.readyState === WebSocket.OPEN) {
|
||||
this.socket.close();
|
||||
// Close the connection if it's still open or still connecting
|
||||
try {
|
||||
if (
|
||||
this.socket.readyState === WebSocket.OPEN ||
|
||||
this.socket.readyState === WebSocket.CONNECTING
|
||||
) {
|
||||
this.socket.close();
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Error while closing WebSocket:", e);
|
||||
}
|
||||
|
||||
this.socket = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user