import { logInfo } from "./logger"; export class SseService { clients = new Set(); addClient(client) { this.clients.add(client); logInfo(`SSE client connected: ${client.id}. Total clients: ${this.clients.size}`); } removeClient(clientId) { const client = [...this.clients].find((c) => c.id === clientId); if (client) { this.clients.delete(client); logInfo(`SSE client disconnected: ${clientId}. Total clients: ${this.clients.size}`); } } notifyClients(event) { this.clients.forEach((client) => { client.send(event); }); } getClientCount() { return this.clients.size; } }