This commit is contained in:
2026-02-25 23:02:51 +01:00
parent dbe429db52
commit 771e8b16f5

View File

@@ -36,6 +36,33 @@ const gameState: GameState = {
players: [],
}
class Host {
private peer: Peer
private connections: DataConnection[]
private gameState: GameState
constructor() {
this.connections = []
this.gameState = {
players: [],
}
}
start() {
this.peer = new Peer({
config: configuration,
})
this.peer.on("connection", this.onConnection)
}
onConnection(conn: DataConnection) {
this.connections.push(conn)
conn.on("open", () => {})
}
}
export async function initWebRTC(
render: (gameState: GameState) => void,
peerId?: string,
@@ -50,7 +77,6 @@ export async function initWebRTC(
peers[conn.peer] = {
lastHeartBeat: new Date().toISOString(),
conn,
}
conn.on("open", () => {