/** * In-memory registry for tracking active bots */ import type { ScreenshareBot } from './ScreenshareBot'; import type { BotStatus } from './types'; class BotRegistry { private bots: Map = new Map(); /** * Register a new bot */ register(botId: string, bot: ScreenshareBot): void { this.bots.set(botId, bot); console.log(`[BotRegistry] Registered bot: ${botId}. Total bots: ${this.bots.size}`); } /** * Get a bot by ID */ get(botId: string): ScreenshareBot | undefined { return this.bots.get(botId); } /** * Remove a bot from registry */ unregister(botId: string): boolean { const result = this.bots.delete(botId); if (result) { console.log(`[BotRegistry] Unregistered bot: ${botId}. Total bots: ${this.bots.size}`); } return result; } /** * Get status of all bots */ getAllStatus(): BotStatus[] { const statuses: BotStatus[] = []; for (const [, bot] of this.bots.entries()) { statuses.push(bot.getStatus()); } return statuses; } /** * Get count of active bots */ getCount(): number { return this.bots.size; } /** * Check if bot exists */ has(botId: string): boolean { return this.bots.has(botId); } } // Export singleton instance export const botRegistry = new BotRegistry();