Lobby Start Mechanik und abfangen aller Möglichen Fehler

This commit is contained in:
2025-03-25 12:01:11 +01:00
parent d299a90067
commit 2e15735b2d
7 changed files with 84 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
class ServerConnectionManager {
constructor() {
/**@type {import("../../../backend/node_modules/socket.io-client".Socket} für Autocompletions VSC*/
this.socket = io(`${window.location.protocol}//${window.location.hostname}:${window.location.port}`);
this.basicSetup();
}
basicSetup() {
this.socket.emit("hereForGame");
this.socket.on("connect", () => {
console.log("Verbindung zum Server hergestellt!");
});
this.socket.on("connect_error", (error) => {
console.log(error);
window.location.pathname = "/dashboard";
});
this.socket.on("disconnect", () => {
console.log("Die verbindung wurde unterbrochen!");
window.location.pathname = "/dashboard";
});
}
}
new ServerConnectionManager();