🚧 test for better error handling

main
Vincent ASTOLFI 3 months ago
parent c7c5337254
commit 1788d3ef6c

@ -44,7 +44,7 @@ app.post('/logIn', (req, res) => {
const query = 'SELECT hashed_password FROM users WHERE pseudo = ?';
db.query(query, [pseudo], async (err, results) => {
if (err) {
console.error('Error inserting user into the database:', err);
console.error('Error selecting user into the database:', err);
return res.status(500).send({message: 'Internal server error.'});
}
if (results.length === 1) {
@ -162,6 +162,12 @@ io.on("connection", (socket) => {
console.log(`Player disconnected: ${socket.id}`);
})
socket.on('delete room', (roomId) => {
const roomIndex = rooms.findIndex((r) => r.id === roomId)
rooms.splice(roomIndex, 1)
console.log(rooms)
})
socket.on("first connection", (socketId) => {
const cookies = socket.request.headers.cookie;
const authToken = cookies.split('; ').find(cookie => cookie.startsWith('authToken=')).split('=')[1];

@ -83,6 +83,10 @@
Validate !
</button>
<button class="btn-primary" id="resetRoom" type="submit">
Reset room
</button>
<p id="playerInfo"></p>
<div id="inGameNotification">

@ -233,4 +233,8 @@ document.getElementById('rematchButton').addEventListener('click', () => {
socket.emit("ask for rematch", roomId, socket.id)
})
document.getElementById('resetRoom').addEventListener('click', () => {
socket.emit("delete room", roomId)
})
setTimeout(startConnection, 100);
Loading…
Cancel
Save