diff --git a/src/net/Socket.ts b/src/net/Socket.ts index 9d1c5ef..bc735b6 100644 --- a/src/net/Socket.ts +++ b/src/net/Socket.ts @@ -30,13 +30,12 @@ export class GameSocket { this.socket.onmessage = (e) => { const msg = JSON.parse(e.data); - switch (msg.type) { - case "init": - this.playerId = msg.payload.id; - break; - case "input": - this.onState?.(msg.payload); - break; + if (msg.type === "init") { + this.playerId = msg.payload.id; + } + + if (msg.type === "input") { + this.onState?.(msg.payload); } };