remove annoying message
This commit is contained in:
parent
bafd0fb153
commit
09f50e2477
2 changed files with 4 additions and 5 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ 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
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue