fix(client): add destructor to UnoClient for resource cleanup

This commit is contained in:
Kieran Kihn
2025-12-10 21:40:58 +08:00
parent 5ff38c2bde
commit 59f8ac8186
2 changed files with 9 additions and 1 deletions

View File

@@ -141,10 +141,17 @@ namespace UNO::CLIENT {
gameUI_ = std::make_shared<UI::GameUI>([this](const PlayerAction &action) { this->handlePlayerAction(action); });
}
UnoClient::~UnoClient()
{
networkClient_->stop();
if (networkThread_.joinable()) {
networkThread_.join();
}
}
void UnoClient::run()
{
networkThread_ = std::thread([this]() { this->networkClient_->run(); });
gameUI_->run();
}
} // namespace UNO::CLIENT

View File

@@ -44,6 +44,7 @@ namespace UNO::CLIENT {
public:
UnoClient();
~UnoClient();
void run();
};