-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/websocket connection check #47
base: main
Are you sure you want to change the base?
Conversation
@@ -55,10 +64,26 @@ function App() { | |||
<p>Left Foot: {stepTime.targetZones.left.min} - {stepTime.targetZones.left.max}</p> | |||
<p>Right Foot: {stepTime.targetZones.right.min} - {stepTime.targetZones.right.max}</p> | |||
<p>Average Target Zone: {stepTime.targetZones.average}</p> | |||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to have this just be as a console message or alert rather than a visualization on the page because it could affect other views. Additionally, it's at the bottom of the page so it might not been seen by the client anyway based on the view. We could leave it as is, just something to consider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, just consider the change I listed as a comment and decide whether or not you'd want to keep it as a
tag or an alert/console message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
in the next sprint, let's remember to initiate an automatic reconnection from the frontend when streaming stops, automatic reload, and if these fail then we can notify the client that something is wrong.
This is because with your current implementation, a break in the system will stop the streaming but does not break the socket connection, so all the backend needs to start sending data again is a little trigger from the frontend.
Fixes: #40
What was changed:
The WebSocket connection handling was updated to ensure data streaming only happens when the WebSocket connection is in the "CONNECTED" state. Additionally, the user interface now provides real-time feedback about the WebSocket connection status using color-coded notifications (green for connected, red for error, yellow for disconnected).
Why was it changed:
This update ensures that data streaming occurs only when the WebSocket is properly connected, which improves the robustness and reliability of the application. It also provides clear feedback to the user about the connection status, helping them understand when there are issues with the WebSocket connection.
How was it changed:
Introduced a state variable (isWebSocketConnected) to track the connection status of the WebSocket.
Updated WebSocket event handlers (onopen, onclose, onerror) to modify the connection status and notify users of connection changes.
The UI was updated to display color-coded status messages, providing clear visual feedback about the WebSocket state.
Ensured that data streaming and communication only take place when the WebSocket is in the "CONNECTED" state.