Open
Conversation
- Enhanced backend broadcast_state to push V2G and AI focus data via WebSocket - Removed all frontend setInterval polling loops in script.js - Implemented WebSocket event listeners for system_update and v2g_restoration_complete - Refactored scenario-director to use event-driven status checks - Updated index.html cache busting to force reload of new scripts Performance: Eliminated ~5-7 req/sec from periodic polling of /api/network_state, /api/v2g/status, and /api/ai/map_focus_status
- Added WebSocket callback to scenario_controller for real-time updates - Replaced setInterval polling in scenario-controls.js with WebSocket listener - Added handleSystemUpdate() to process scenario data from system_update events - Removed 3-second polling loop for scenario status updates Part of: WebSocket migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
📋 Description
This PR completes the migration from an HTTP polling architecture to a real-time WebSocket push model. It eliminates periodic
GETrequests for Network State, V2G Status, AI Map Focus, and Scenario Controller updates, replacing them with event-drivensystem_updateandv2g_restoration_completeWebSocket events.This change significantly reduces network overhead (~5-7 req/sec per client eliminated) and improves the responsiveness of the frontend application by delivering updates in real-time rather than on fixed polling intervals.
Fixes #(ISSUE_NUMBER)
🔄 Type of Change
Please delete options that are not relevant.
🧪 Testing
Manual verification performed to ensure real-time data synchronization between backend and frontend without polling.
Test Configuration:
Verification Methods:
📸 Screenshots (if applicable)
Before:
(Network tab showing continuous polling requests every 1-3 seconds)
After:
(Network tab showing 0 polling requests - only WebSocket traffic and initial page load)
✅ Checklist
🔧 Implementation Details
Changes Made
broadcast_state()to include V2G active vehicle data and AI map focus coordinates in thesystem_updatepayload.v2g_websocket_callback()to bridge V2G manager events with WebSocket emissions and registered it for real-time restoration notifications.updateLoop()(2s interval) andupdateV2GColorsOptimized()(5s interval) polling loops. AddedupdateV2GFromWebSocket()andapplyAIMapFocus()listeners.startChatbotMonitoring()polling loop and added WebSocket listener forv2g_restoration_completeevents.?v=nocache_<timestamp>) to force browser reload of updated JavaScript files.Architecture Impact
/api/network_state,/api/v2g/status,/api/ai/map_focus_status.system_updatenow carries V2G and AI focus data; newv2g_restoration_completeevent added.Performance Considerations
setTimeoutandsetIntervalcalls.🔄 Migration Notes
📋 Dependencies
No new dependencies required. Utilizes existing infrastructure (Socket.IO, Flask-SocketIO).
🔗 Related Issues/PRs
📚 Documentation
🚀 Deployment Notes
🧑💻 Reviewer Notes
Please pay special attention to:
v2g_restoration_completeevents don't arrive before frontend initialization.system_updateevents contain V2G and AI focus data.📝 Additional Notes
This PR represents the complete elimination of HTTP polling. The backend and frontend are now fully event-driven for Network, V2G, and Scenario status.