Lobby Start Mechanik und abfangen aller Möglichen Fehler
This commit is contained in:
17
frontend/game/index.html
Normal file
17
frontend/game/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Doublesnake - Game</title>
|
||||
<link rel="stylesheet" href="../style/generalStyle.css">
|
||||
<link rel="stylesheet" href="./style/mainStyle.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
<script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
|
||||
<script type="module" src="./scripts/index.js"></script>
|
||||
|
||||
</html>
|
||||
28
frontend/game/scripts/index.js
Normal file
28
frontend/game/scripts/index.js
Normal 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();
|
||||
0
frontend/game/style/mainStyle.css
Normal file
0
frontend/game/style/mainStyle.css
Normal file
Reference in New Issue
Block a user