WS improvements

This commit is contained in:
2025-02-10 13:59:25 +01:00
parent 9030550c0f
commit cfaea6ec7c
3 changed files with 46 additions and 6 deletions

View File

@ -8,16 +8,14 @@ import WorldRepository from '#repositories/worldRepository'
class DateManager {
private static readonly CONFIG = {
GAME_SPEED: 8, // 24 game hours / 3 real hours
UPDATE_INTERVAL: 1000 // 1 second
UPDATE_INTERVAL: 1000, // 1 minute
} as const
private io: Server | null = null
private intervalId: NodeJS.Timeout | null = null
private currentDate = new Date()
private readonly logger = Logger.type(LoggerType.APP)
private currentDate = new Date()
private intervalId: NodeJS.Timeout | null = null
public async boot(): Promise<void> {
this.io = SocketManager.getIO()
await this.loadDate()
this.startDateLoop()
this.logger.info('Date manager loaded')
@ -85,7 +83,8 @@ class DateManager {
}
private emitDate(): void {
this.io?.emit('date', this.currentDate)
const io = SocketManager.getIO()
io?.emit('date', this.currentDate)
}
private async saveDate(): Promise<void> {