Initial commit: Gaming Hub foundation
Plugin-based Discord bot framework with web frontend: - Core: Discord.js client, SSE broadcast, JSON persistence - Plugin system: lifecycle hooks (init, onReady, routes, snapshot, destroy) - Web: React 19 + Vite 6 + TypeScript, tab-based navigation - Docker: multi-stage build (Node 24, static ffmpeg, yt-dlp) - GitLab CI: Kaniko with LAN registry caching Ready for plugin development.
This commit is contained in:
parent
1ae431dd2f
commit
ae1c41f0ae
19 changed files with 954 additions and 0 deletions
22
server/src/core/sse.ts
Normal file
22
server/src/core/sse.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { Response } from 'express';
|
||||
|
||||
const sseClients = new Set<Response>();
|
||||
|
||||
export function addSSEClient(res: Response): void {
|
||||
sseClients.add(res);
|
||||
}
|
||||
|
||||
export function removeSSEClient(res: Response): void {
|
||||
sseClients.delete(res);
|
||||
}
|
||||
|
||||
export function sseBroadcast(data: Record<string, any>): void {
|
||||
const msg = `data: ${JSON.stringify(data)}\n\n`;
|
||||
for (const c of sseClients) {
|
||||
try { c.write(msg); } catch { sseClients.delete(c); }
|
||||
}
|
||||
}
|
||||
|
||||
export function getSSEClientCount(): number {
|
||||
return sseClients.size;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue