mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-05-15 03:25:40 +08:00
- Add collapsible sidebar with phase stepper (jump between phases) - Add SimBridge conditions panel in sidebar (live values, progress bars, targets) - Add global progress bar (top edge, glowing) + phase-local TTS progress bar - Add skip button to skip TTS speech while ATC is speaking - Add skipSpeech() to audio composable (stops current Pizzicato sound) - Wire up bridge data.post.ts with user auth (JWT) + example payload - Add server-side telemetry store with pub/sub for Bridge→WS relay - Extend WS handler with subscribe-telemetry message + userId tracking - Extend sync composable with subscribeTelemetry() + onTelemetry() callback - Add require-auth middleware to all flightlab pages - Fix instructor station ECONNREFUSED via import.meta.client guard - Add animations: phase transitions, button lists, fade-scale, check-pop, pulse Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* In-memory telemetry store that bridges the HTTP POST endpoint
|
|
* with FlightLab WebSocket sessions.
|
|
*
|
|
* Flow: SimBridge → POST /api/bridge/data → telemetryStore → WS → Client
|
|
*/
|
|
|
|
type TelemetryListener = (userId: string, data: any) => void
|
|
|
|
class FlightLabTelemetryStore {
|
|
/** Latest telemetry per userId */
|
|
private data = new Map<string, any>()
|
|
/** WebSocket listeners that get notified on new data */
|
|
private listeners = new Set<TelemetryListener>()
|
|
|
|
update(userId: string, telemetry: any) {
|
|
this.data.set(userId, { ...telemetry, timestamp: Date.now() })
|
|
// Notify all listeners (WebSocket handler subscribes here)
|
|
for (const listener of this.listeners) {
|
|
try { listener(userId, this.data.get(userId)) } catch {}
|
|
}
|
|
}
|
|
|
|
get(userId: string) {
|
|
return this.data.get(userId) ?? null
|
|
}
|
|
|
|
subscribe(listener: TelemetryListener) {
|
|
this.listeners.add(listener)
|
|
return () => { this.listeners.delete(listener) }
|
|
}
|
|
}
|
|
|
|
// Singleton — shared across all server handlers
|
|
export const flightlabTelemetryStore = new FlightLabTelemetryStore()
|