diff --git a/nginx.conf b/nginx.conf
index 25c09b3d..57288cdd 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -297,4 +297,4 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
-}
\ No newline at end of file
+}
diff --git a/src/client/index.html b/src/client/index.html
index ae94e0ae..be22fefc 100644
--- a/src/client/index.html
+++ b/src/client/index.html
@@ -203,7 +203,7 @@
/>
-
+
diff --git a/src/server/Worker.ts b/src/server/Worker.ts
index 5bee6b60..13110598 100644
--- a/src/server/Worker.ts
+++ b/src/server/Worker.ts
@@ -294,72 +294,78 @@ export function startWorker() {
try {
// Parse and handle client messages
- const parsed = ClientJoinMessageSchema.safeParse(
- JSON.parse(message.toString()),
- );
- if (!parsed.success) {
- const error = z.prettifyError(parsed.error);
- log.warn("Error parsing join message client", error);
- ws.close();
- return;
- }
- const clientMsg = parsed.data;
-
- if (clientMsg.type === "join") {
- // Verify this worker should handle this game
- const expectedWorkerId = config.workerIndex(clientMsg.gameID);
- if (expectedWorkerId !== workerId) {
- log.warn(
- `Worker mismatch: Game ${clientMsg.gameID} should be on worker ${expectedWorkerId}, but this is worker ${workerId}`,
- );
+ log.warn(`Raw WebSocket message: ${message.toString()}`);
+ const raw = JSON.parse(message.toString());
+
+ if (raw?.type === "join") {
+ const parsed = ClientJoinMessageSchema.safeParse(
+ JSON.parse(message.toString()),
+ );
+ if (!parsed.success) {
+ log.warn("ClientJoinMessage parsing failed:");
+ for (const issue of parsed.error.errors) {
+ log.warn(` → [${issue.path.join(".")}] ${issue.message}`);
+ }
+ ws.close();
return;
}
+ const clientMsg = parsed.data;
+
+ if (clientMsg.type === "join") {
+ // Verify this worker should handle this game
+ const expectedWorkerId = config.workerIndex(clientMsg.gameID);
+ if (expectedWorkerId !== workerId) {
+ log.warn(
+ `Worker mismatch: Game ${clientMsg.gameID} should be on worker ${expectedWorkerId}, but this is worker ${workerId}`,
+ );
+ return;
+ }
- const { persistentId, claims } = await verifyClientToken(
- clientMsg.token,
- config,
- );
+ const { persistentId, claims } = await verifyClientToken(
+ clientMsg.token,
+ config,
+ );
- let roles: string[] | undefined;
+ let roles: string[] | undefined;
- // Check user roles
- if (claims !== null) {
- const result = await getUserMe(clientMsg.token, config);
- if (result === false) {
- log.warn("Token is not valid", claims);
- return;
+ // Check user roles
+ if (claims !== null) {
+ const result = await getUserMe(clientMsg.token, config);
+ if (result === false) {
+ log.warn("Token is not valid", claims);
+ return;
+ }
+ roles = result.player.roles;
}
- roles = result.player.roles;
- }
- // TODO: Validate client settings based on roles
-
- // Create client and add to game
- const client = new Client(
- clientMsg.clientID,
- persistentId,
- claims,
- roles,
- ip,
- clientMsg.username,
- ws,
- clientMsg.flag,
- );
-
- const wasFound = gm.addClient(
- client,
- clientMsg.gameID,
- clientMsg.lastTurn,
- );
+ // TODO: Validate client settings based on roles
+
+ // Create client and add to game
+ const client = new Client(
+ clientMsg.clientID,
+ persistentId,
+ claims,
+ roles,
+ ip,
+ clientMsg.username,
+ ws,
+ clientMsg.flag,
+ );
- if (!wasFound) {
- log.info(
- `game ${clientMsg.gameID} not found on worker ${workerId}`,
+ const wasFound = gm.addClient(
+ client,
+ clientMsg.gameID,
+ clientMsg.lastTurn,
);
- // Handle game not found case
+
+ if (!wasFound) {
+ log.info(
+ `game ${clientMsg.gameID} not found on worker ${workerId}`,
+ );
+ // Handle game not found case
+ }
}
}
-
// Handle other message types
} catch (error) {
log.warn(
diff --git a/supervisord.conf b/supervisord.conf
index c31d0429..086622a6 100644
--- a/supervisord.conf
+++ b/supervisord.conf
@@ -22,4 +22,4 @@ user=node
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
-stderr_logfile_maxbytes=0
\ No newline at end of file
+stderr_logfile_maxbytes=0
diff --git a/webpack.config.js b/webpack.config.js
index 70ee9452..3f6d2893 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -159,7 +159,7 @@ export default async (env, argv) => {
},
historyApiFallback: true,
compress: true,
- port: 3000,
+ port: 9000,
proxy: [
// WebSocket proxies
{