reconexion basada en el UUID
This commit is contained in:
@@ -115,6 +115,36 @@ onMounted(async () => {
|
||||
const room = await colyseusService.joinLobby();
|
||||
colorInput.value = colyseusService.playerColor.value || '#667eea';
|
||||
|
||||
// Prefer reconnection token path to bypass locked rooms
|
||||
room.onMessage("resumeReconnection", async (data: any) => {
|
||||
try {
|
||||
await colyseusService.reconnectWithToken(data.token);
|
||||
// Leave lobby before navigating
|
||||
if (colyseusService.lobbyRoom.value) {
|
||||
colyseusService.lobbyRoom.value.leave();
|
||||
colyseusService.lobbyRoom.value = null;
|
||||
}
|
||||
await router.push(`/${routeUuid.value}/demo`);
|
||||
} catch (error) {
|
||||
console.error('Reconnection failed:', error);
|
||||
}
|
||||
});
|
||||
|
||||
// Listen for server-initiated resume to existing game (fallback joinById)
|
||||
room.onMessage("resumeGame", async (data: any) => {
|
||||
try {
|
||||
const gameRoom = await colyseusService.joinGameRoom(data.roomId);
|
||||
// Leave lobby before navigating
|
||||
if (colyseusService.lobbyRoom.value) {
|
||||
colyseusService.lobbyRoom.value.leave();
|
||||
colyseusService.lobbyRoom.value = null;
|
||||
}
|
||||
await router.push(`/${routeUuid.value}/demo`);
|
||||
} catch (error) {
|
||||
console.error('Auto-join failed:', error);
|
||||
}
|
||||
});
|
||||
|
||||
// Keep color input synced with server-updated color
|
||||
watch(() => colyseusService.playerColor.value, (c) => {
|
||||
if (c && c !== colorInput.value) colorInput.value = c;
|
||||
|
||||
Reference in New Issue
Block a user