added LoginPage

This commit is contained in:
Wenszel
2023-11-23 21:20:44 +01:00
parent c999bfca39
commit ffaaf0b6f3
10 changed files with 228 additions and 29 deletions
+20
View File
@@ -15,5 +15,25 @@ module.exports = (io, socket) => {
io.to(socket.id).emit('room:data', JSON.stringify(room));
}
};
const getRooms = async () => {
let rooms = await RoomModel.find({});
const response = [];
rooms.forEach(room => {
if (!room.isStarted && !room.isFull()) {
response.push({
_id: room._id,
name: room.name,
players: room.players,
isStarted: room.isStarted,
});
}
});
io.to(socket.id).emit('room:rooms', JSON.stringify(response));
};
socket.on('room:data', getData);
socket.on('room:rooms', getRooms);
};