reconexio

This commit is contained in:
2025-08-15 19:58:09 -06:00
parent 5e42eb7d54
commit 9b84008f19
4 changed files with 51 additions and 31 deletions

View File

@@ -115,8 +115,12 @@ onMounted(async () => {
const room = await colyseusService.joinLobby();
colorInput.value = colyseusService.playerColor.value || '#667eea';
let resumed = false;
const guardResume = () => { if (resumed) return true; resumed = true; return false; };
// Prefer reconnection token path to bypass locked rooms
room.onMessage("resumeReconnection", async (data: any) => {
if (guardResume()) return;
try {
await colyseusService.reconnectWithToken(data.token);
// Leave lobby before navigating
@@ -132,6 +136,7 @@ onMounted(async () => {
// Listen for server-initiated resume to existing game (fallback joinById)
room.onMessage("resumeGame", async (data: any) => {
if (guardResume()) return;
try {
const gameRoom = await colyseusService.joinGameRoom(data.roomId);
// Leave lobby before navigating