mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
fix(client): add destructor to UnoClient for resource cleanup
This commit is contained in:
@@ -141,10 +141,17 @@ namespace UNO::CLIENT {
|
|||||||
gameUI_ = std::make_shared<UI::GameUI>([this](const PlayerAction &action) { this->handlePlayerAction(action); });
|
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()
|
void UnoClient::run()
|
||||||
{
|
{
|
||||||
networkThread_ = std::thread([this]() { this->networkClient_->run(); });
|
networkThread_ = std::thread([this]() { this->networkClient_->run(); });
|
||||||
gameUI_->run();
|
gameUI_->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace UNO::CLIENT
|
} // namespace UNO::CLIENT
|
||||||
@@ -44,6 +44,7 @@ namespace UNO::CLIENT {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
UnoClient();
|
UnoClient();
|
||||||
|
~UnoClient();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user