remove annoying message

This commit is contained in:
Didictateur 2025-11-09 17:48:59 +01:00
parent bafd0fb153
commit 09f50e2477
2 changed files with 4 additions and 5 deletions

View file

@ -106,9 +106,8 @@
socket.emit('room:join', { roomId, playerId }, (resp)=>{ socket.emit('room:join', { roomId, playerId }, (resp)=>{
if(resp && resp.error){ if(resp && resp.error){
console.warn('join error', resp); console.warn('join error', resp);
alert(resp.error || 'Impossible de rejoindre la room'); // do not alert or force-redirect; show error in status and keep page for debugging/retry
// redirect back to home to let user retry/create try{ document.getElementById('status').textContent = resp.error || 'Impossible de rejoindre la room'; }catch(e){}
window.location.href = '/';
return; return;
} }
myPlayerId = resp.playerId; myPlayerId = resp.playerId;

View file

@ -42,8 +42,7 @@ io.on('connection', (socket) => {
socket.on('room:join', ({ roomId, playerId }, cb) => { socket.on('room:join', ({ roomId, playerId }, cb) => {
const room = rooms.get(roomId); const room = rooms.get(roomId);
if (!room) return cb && cb({ error: 'room not found' }); if (!room) return cb && cb({ error: 'room not found' });
if (room.players.length >= 2) return cb && cb({ error: 'room full' }); const assignedId = playerId || uuidv4();
const assignedId = playerId || uuidv4();
// If this player was pending removal (disconnect during navigation), cancel removal // If this player was pending removal (disconnect during navigation), cancel removal
if(room.removalTimers && room.removalTimers.has(assignedId)){ if(room.removalTimers && room.removalTimers.has(assignedId)){
@ -53,6 +52,7 @@ io.on('connection', (socket) => {
// If playerId corresponds to an existing player, treat this as a reconnection // If playerId corresponds to an existing player, treat this as a reconnection
let existing = room.players.find(p => p.id === assignedId); let existing = room.players.find(p => p.id === assignedId);
let color; let color;
if(existing){ if(existing){
existing.socketId = socket.id; existing.socketId = socket.id;