feat: implement initial Deno server with WebSocket API, static file serving, and development Docker Compose.
All checks were successful
Build and Push Docker Image / docker (push) Successful in 21s
All checks were successful
Build and Push Docker Image / docker (push) Successful in 21s
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
$npYear,
|
||||
} from "./dom.js";
|
||||
import { state } from "./state.js";
|
||||
import { cacheLastRoomId, cacheSessionId, sendMsg } from "./ws.js";
|
||||
import { cacheLastRoomId, cacheSessionId, clearSessionId, sendMsg } from "./ws.js";
|
||||
import { renderRoom } from "./render.js";
|
||||
import { applySync, loadTrack, getSound } from "./audio.js";
|
||||
|
||||
@@ -19,10 +19,10 @@ function updatePlayerIdFromRoom(r) {
|
||||
state.playerId = only.id;
|
||||
try {
|
||||
localStorage.setItem("playerId", only.id);
|
||||
} catch {}
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
function shortName(id) {
|
||||
@@ -35,7 +35,7 @@ export function handleConnected(msg) {
|
||||
state.playerId = msg.playerId;
|
||||
try {
|
||||
if (msg.playerId) localStorage.setItem("playerId", msg.playerId);
|
||||
} catch {}
|
||||
} catch { }
|
||||
if (msg.sessionId) {
|
||||
const existing = localStorage.getItem("sessionId");
|
||||
if (!existing) cacheSessionId(msg.sessionId);
|
||||
@@ -51,7 +51,7 @@ export function handleConnected(msg) {
|
||||
try {
|
||||
updatePlayerIdFromRoom(state.room);
|
||||
renderRoom(state.room);
|
||||
} catch {}
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ export function onMessage(ev) {
|
||||
state.playerId = msg.playerId;
|
||||
try {
|
||||
localStorage.setItem("playerId", msg.playerId);
|
||||
} catch {}
|
||||
} catch { }
|
||||
}
|
||||
const code =
|
||||
msg.roomId || state.room?.id || localStorage.getItem("lastRoomId");
|
||||
@@ -187,11 +187,23 @@ export function onMessage(ev) {
|
||||
if (state.room) {
|
||||
try {
|
||||
renderRoom(state.room);
|
||||
} catch {}
|
||||
} catch { }
|
||||
}
|
||||
// Restore player name after successful resume
|
||||
import("./session.js").then(({ reusePlayerName }) => {
|
||||
reusePlayerName();
|
||||
});
|
||||
} else {
|
||||
// Resume failed - session expired or server restarted
|
||||
// Clear stale session ID so next connect gets a fresh one
|
||||
clearSessionId();
|
||||
// Still try to join the last room
|
||||
const code = state.room?.id || localStorage.getItem("lastRoomId");
|
||||
if (code) sendMsg({ type: "join_room", roomId: code });
|
||||
// Restore player name even on failed resume (new player, same name)
|
||||
import("./session.js").then(({ reusePlayerName }) => {
|
||||
reusePlayerName();
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user