chore: refactor sdk bridge #71
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only publishes requested telemetry
When an overlay subscribes to a telemetry key on the telemetry store, IPC message is sent to the backend and the SDK will now append taht key to publish to that overlay.
After this change only the telemetry values that are needed are published to the windows for each overlay.
graph TD A[iRacing SDK] -->|Raw Telemetry Data| B[IRacingSDK Bridge] B -->|Full Telemetry Object| C[OverlayManager] D[Frontend Overlay] -->|useTelemetryFieldTracker hook| E[TelemetryStore] E -->|subscribeToTelemetryFields| F[IPC: subscribe-telemetry-fields] F -->|IPC Message| G[TelemetryBridge] G -->|Overlay ID + Fields| H[OverlayManager] H -->|Track Subscriptions| I[fieldSubscriptions Map] H -->|Track Field Mappings| J[fieldToOverlays Map] C -->|publishTelemetryFields| K{For each telemetry field} K -->|Check fieldToOverlays| L[Get subscribed overlays] L -->|Create OverlayTelemetryPayload| M[Send only subscribed fields] M -->|Targeted IPC| N[Specific Overlay Window] N -->|telemetry event| O[Frontend TelemetryProvider] O -->|Update TelemetryStore| P[Component re-renders] Q[Overlay Cleanup] -->|unsubscribeFromTelemetryFields| H H -->|Remove from maps| R[Clean up subscriptions] style A fill:#e1f5fe style D fill:#f3e5f5 style H fill:#fff3e0 style M fill:#e8f5e8