[api] Connected Condition - state_subscription_only flag (#11906)

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Flo
2025-11-24 18:49:16 +01:00
committed by GitHub
parent b820e67616
commit 09f3f62194
4 changed files with 39 additions and 5 deletions

View File

@@ -528,7 +528,18 @@ void APIServer::request_time() {
}
#endif
bool APIServer::is_connected() const { return !this->clients_.empty(); }
bool APIServer::is_connected(bool state_subscription_only) const {
if (!state_subscription_only) {
return !this->clients_.empty();
}
for (const auto &client : this->clients_) {
if (client->flags_.state_subscription) {
return true;
}
}
return false;
}
void APIServer::on_shutdown() {
this->shutting_down_ = true;