Enhancements to WebSocket Connection Management and Unit Tests
Summary:
This pull request introduces improvements to the existing WebSocket (ws) connection management and functional unit tests. Key changes include:
WebSocket Connection Cleanup: I've extended the current functionality that monitors and terminates stale ws connections. Now, when a ws connection is closed—whether due to inactivity or explicitly by a user—it's also removed from the user2ws map. This map maintains a record of active ws connections for each user, ensuring the list remains accurate and up-to-date.
Unit Test Refactoring: A failing functional unit test caused by the above changes highlighted an issue where WebSocket connections were closed immediately after message receipt, hindering subsequent commands within the same test scenario. To address this, I refactored the existing function-based approach into a more robust class. This class establishes a WebSocket connection and provides methods for sending commands and closing the ws connection. This enhancement simplifies test scenarios involving multiple commands and avoids the overhead of repeatedly opening and closing connections.
Enhancements to WebSocket Connection Management and Unit Tests
Summary:
This pull request introduces improvements to the existing WebSocket (ws) connection management and functional unit tests. Key changes include:
WebSocket Connection Cleanup: I've extended the current functionality that monitors and terminates stale ws connections. Now, when a ws connection is closed—whether due to inactivity or explicitly by a user—it's also removed from the user2ws map. This map maintains a record of active ws connections for each user, ensuring the list remains accurate and up-to-date.
Unit Test Refactoring: A failing functional unit test caused by the above changes highlighted an issue where WebSocket connections were closed immediately after message receipt, hindering subsequent commands within the same test scenario. To address this, I refactored the existing function-based approach into a more robust class. This class establishes a WebSocket connection and provides methods for sending commands and closing the ws connection. This enhancement simplifies test scenarios involving multiple commands and avoids the overhead of repeatedly opening and closing connections.