Refactor index.html to use separate files for scripts and style
This commit is contained in:
parent
6baa194e5b
commit
cd21e4e8bd
6 changed files with 129 additions and 158 deletions
11
src/index.ts
11
src/index.ts
|
|
@ -22,20 +22,15 @@ const app = new Elysia()
|
|||
}),
|
||||
open(ws) {
|
||||
const { gameId, playerId } = ws.data.query;
|
||||
|
||||
if (!gameId || !playerId) {
|
||||
console.error(
|
||||
'WebSocket connection missing gameId or playerId in query params.',
|
||||
);
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: 'error',
|
||||
error: 'Missing gameId or playerId.',
|
||||
}),
|
||||
);
|
||||
ws.send('Error: missing gameId or playerId.');
|
||||
ws.close();
|
||||
return;
|
||||
}
|
||||
|
||||
wsHandler.handleConnection(ws, gameId, playerId);
|
||||
|
||||
const game = wsHandler.getGame(gameId);
|
||||
|
|
@ -47,7 +42,7 @@ const app = new Elysia()
|
|||
} else if (game.getPlayerCount() === 1 && game.status === 'waiting') {
|
||||
message = `You are ${playerId}. Waiting for another player to join.`;
|
||||
}
|
||||
wsHandler.sendMessage(game.id, 'message', message, ws);
|
||||
wsHandler.sendMessage(game.id, message, ws);
|
||||
} else {
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue