From a54b315e5d994270c34ec2be4718d7e7986cae90 Mon Sep 17 00:00:00 2001 From: Smile Rex Date: Thu, 22 Jan 2026 16:54:56 +0300 Subject: [PATCH] fix msg types --- src/net/Socket.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/net/Socket.ts b/src/net/Socket.ts index fe98300..9d1c5ef 100644 --- a/src/net/Socket.ts +++ b/src/net/Socket.ts @@ -30,12 +30,13 @@ export class GameSocket { this.socket.onmessage = (e) => { const msg = JSON.parse(e.data); - if (msg.type === "init") { - this.playerId = msg.payload.id; - } - - if (msg.type === "state") { - this.onState?.(msg.payload); + switch (msg.type) { + case "init": + this.playerId = msg.payload.id; + break; + case "input": + this.onState?.(msg.payload); + break; } };