This commit is contained in:
2026-02-24 19:51:11 +01:00
parent 16519532c1
commit 1a43e5192b

View File

@@ -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}`);
});