WIP, tout est en chantier, très content :)
This commit is contained in:
30
src/server/class/GameSession.ts
Normal file
30
src/server/class/GameSession.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ClientPlayer } from "./Client";
|
||||
import {gameUpdate} from "../gameUpdate.js"
|
||||
import { GameComponentsServer } from "./GameComponentsServer";
|
||||
|
||||
// Empty object replacement to the web-API (web-API useless on server-side)
|
||||
|
||||
class GameSession {
|
||||
id: string; // url ?
|
||||
playersMap: Map<string, ClientPlayer>;
|
||||
unreadyPlayersMap: Map<string, ClientPlayer>;
|
||||
updateInterval: NodeJS.Timer;
|
||||
// gc: GameComponentsServer;
|
||||
// updateInterval: NodeJS.Timer;
|
||||
constructor(id: string) {
|
||||
this.id = id;
|
||||
this.playersMap = new Map();
|
||||
this.unreadyPlayersMap = new Map();
|
||||
// this.gc = new GameComponentsServer();
|
||||
}
|
||||
start() {
|
||||
this.updateInterval = setInterval( () => {
|
||||
const update = gameUpdate();
|
||||
this.playersMap.forEach( (client) => {
|
||||
client.socket.send(JSON.stringify(update));
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
export {GameSession}
|
||||
Reference in New Issue
Block a user