From 5bb98cd7fce64b22b740b4bf99080a6d56e00b4a Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 28 May 2025 06:17:37 +0200 Subject: [PATCH] Refactor spirit message handling in app.js --- node/server/public/app.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/node/server/public/app.js b/node/server/public/app.js index fd85f16..a36df93 100644 --- a/node/server/public/app.js +++ b/node/server/public/app.js @@ -270,8 +270,13 @@ class SpinnerController { this.ws.addEventListener('message', async (event) => { const msg = JSON.parse(event.data); if (msg.type === 'spirit') { - // Beachte: Neues Handling mit Lebenszeit-Offset! - spawnSpiritWithOffset(msg.data, msg.timeSinceSpawnMs, msg.spiritIntervalMs); + if (typeof msg.timeSinceSpawnMs === "number" && msg.timeSinceSpawnMs > 0) { + // Initiale Verbindung: Mit Offset + spawnSpiritWithOffset(msg.data, msg.timeSinceSpawnMs, msg.spiritIntervalMs); + } else { + // Normales Timer-Event + spawnSpirit(msg.data); + } } }); this.ws.addEventListener('close', () => {