This commit is contained in:
IM23a-spirgif
2025-05-06 15:51:21 +02:00
parent 687748ed85
commit 4a92b61930
+4
View File
@@ -238,9 +238,11 @@ app.get("/lobby/join", authenticateToken, async (req, res) => {
app.delete("/lobby/leave", authenticateToken, async (req, res) => { app.delete("/lobby/leave", authenticateToken, async (req, res) => {
const lobbyId = req.query.lobbyId; const lobbyId = req.query.lobbyId;
const username = req.query.username; const username = req.query.username;
if (!lobbyId || !username) { if (!lobbyId || !username) {
return res.status(400).json({ error: "Missing lobbyId or username" }); return res.status(400).json({ error: "Missing lobbyId or username" });
} }
if (lobbyId in playerMap) { if (lobbyId in playerMap) {
const index = playerMap[lobbyId].indexOf(username); const index = playerMap[lobbyId].indexOf(username);
if (index > -1) { if (index > -1) {
@@ -250,9 +252,11 @@ app.delete("/lobby/leave", authenticateToken, async (req, res) => {
return res.status(404).json({ error: "User not in lobby" }); return res.status(404).json({ error: "User not in lobby" });
} }
} }
res.status(404).json({ error: "Lobby not found" }); res.status(404).json({ error: "Lobby not found" });
}); });
app.get("/lobby/players", authenticateToken, async (req, res) => { app.get("/lobby/players", authenticateToken, async (req, res) => {
let lobbyId = req.query.lobbyId; let lobbyId = req.query.lobbyId;
let players = playerMap[lobbyId] || []; let players = playerMap[lobbyId] || [];