From 594921352c8d82fe5f1a6201a4d5f9fbd9b719fc Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sat, 26 Aug 2023 13:54:39 -0600 Subject: [PATCH] make fetchHadler synchronous only --- engine/systems/Input.ts | 8 ++++++-- server/src/server.ts | 7 ++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engine/systems/Input.ts b/engine/systems/Input.ts index 4a5a3c3..8a68905 100644 --- a/engine/systems/Input.ts +++ b/engine/systems/Input.ts @@ -75,13 +75,17 @@ export class Input extends System { PhysicsConstants.MAX_JUMP_TIME_MS ) { const mass = entity.getComponent(ComponentNames.Mass).mass; - entity.getComponent(ComponentNames.Forces)?.forces.push({ + + const jumpForce = { fCartesian: { fy: mass * PhysicsConstants.PLAYER_JUMP_ACC, fx: 0 }, torque: 0 - }); + }; + entity + .getComponent(ComponentNames.Forces) + ?.forces.push(jumpForce); } } } diff --git a/server/src/server.ts b/server/src/server.ts index 6acbe74..303d2b5 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -65,10 +65,10 @@ export class GameServer { const { sessionId } = websocket.data; const sessionEntities = this.sessions.get(sessionId)!.controllableEntities; - this.sessions.delete(sessionId); if (!sessionEntities) return; + this.messagePublisher.addMessage({ type: MessageType.REMOVE_ENTITIES, body: Array.from(sessionEntities) @@ -103,10 +103,7 @@ export class GameServer { this.sessions.get(sessionId)!.controllableEntities.add(player.id); } - private fetchHandler( - req: Request, - server: Server - ): Promise | Response { + private fetchHandler(req: Request, server: Server): Response { const url = new URL(req.url); const headers = new Headers();