Refactored chatClient.py