import LobbyHandler from "./Handler/LobbyHandler.js"; class ServerConnectionManager { constructor() { /**@type {import("../../../../backend/node_modules/socket.io-client".Socket} für Autocompletions VSC*/ this.socket = io(`http://${window.location.hostname}:${window.location.port}`); this.lobbyContainer = document.getElementById("mainDiv"); this.createBtn = document.getElementById("createBtn"); this.joinOverlayBtn = document.getElementById("joinOverlayBtn"); this.leaveBtn = document.getElementById("leaveBtn"); this.lobbyHandler = new LobbyHandler(this.socket); this.basicSetup(); this.addButtonHandler(); } basicSetup() { this.socket.emit("hereForLobby"); 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"; }) } addButtonHandler() { this.createBtn.addEventListener("click", () => { this.lobbyHandler.handleCreateClick(); }); this.joinOverlayBtn.addEventListener("click", () => { this.lobbyContainer.innerHTML = `