diff --git a/src/multiplayer.ts b/src/multiplayer.ts index 2f3b283..6f9db8c 100644 --- a/src/multiplayer.ts +++ b/src/multiplayer.ts @@ -27,6 +27,10 @@ const configuration: RTCConfiguration = { ], }; +type Message = { + type: "HeartBeat" | "GameState" | "UpdatePosition"; +}; + export async function initWebRTC(peerId?: string) { const peer = new Peer({ config: configuration, @@ -36,7 +40,7 @@ export async function initWebRTC(peerId?: string) { console.log(`Connection received from: ${conn.peer}`); conn.on("open", () => { - conn.on("data", (data) => { + conn.on("data", (data: Message) => { console.log(`Data: ${data}`); }); @@ -52,7 +56,7 @@ export async function initWebRTC(peerId?: string) { const conn = peer.connect(peerId); conn.on("open", () => { - conn.on("data", (data) => { + conn.on("data", (data: Message) => { console.log(`Data: ${data}`); });