Description:
As part of the CrewStand project, to enhance real-time monitoring capabilities, we need to implement a WebSocket route on the backend. This route will publish each sensor reading as soon as it is received, allowing clients to subscribe and receive updates in real-time.
Requirements:
WebSocket Endpoint:
Implement a WebSocket endpoint (e.g., /ws/sensors) that clients can connect to in order to receive real-time sensor readings.
Publish Sensor Readings:
Ensure that each sensor reading received by the /v1/sensors/flowmeters/{id}/reading endpoint is published to all connected WebSocket clients.
The data published should conform to the SensorReading schema.
Client Management:
Manage client connections, ensuring that new clients can connect and subscribe to sensor updates.
Handle client disconnections gracefully, ensuring server stability.
Error Handling:
Implement robust error handling, ensuring any issues with client connections or data publishing are handled gracefully.
Ensure server logs provide meaningful information for any errors encountered.
Testing:
Write unit and integration tests to ensure the WebSocket route works correctly.
Test client connections, data publishing, and disconnections to ensure robustness.
Example WebSocket Message:
The messages sent over the WebSocket should follow the SensorReading schema:
Description: As part of the CrewStand project, to enhance real-time monitoring capabilities, we need to implement a WebSocket route on the backend. This route will publish each sensor reading as soon as it is received, allowing clients to subscribe and receive updates in real-time.
Requirements:
WebSocket Endpoint:
/ws/sensors
) that clients can connect to in order to receive real-time sensor readings.Publish Sensor Readings:
/v1/sensors/flowmeters/{id}/reading
endpoint is published to all connected WebSocket clients.SensorReading
schema.Client Management:
Error Handling:
Testing:
Example WebSocket Message: The messages sent over the WebSocket should follow the
SensorReading
schema:Acceptance Criteria:
Additional Information:
SensorReading
schema as described