mirror of
https://github.com/esphome/esphome.git
synced 2025-10-05 19:33:47 +01:00
preen
This commit is contained in:
@@ -176,8 +176,14 @@ void APIServer::loop() {
|
|||||||
while (client_index < this->clients_.size()) {
|
while (client_index < this->clients_.size()) {
|
||||||
auto &client = this->clients_[client_index];
|
auto &client = this->clients_[client_index];
|
||||||
|
|
||||||
if (client->remove_) {
|
if (!client->remove_) {
|
||||||
// Handle disconnection
|
// Common case: process active client
|
||||||
|
client->loop();
|
||||||
|
client_index++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rare case: handle disconnection
|
||||||
this->client_disconnected_trigger_->trigger(client->client_info_, client->client_peername_);
|
this->client_disconnected_trigger_->trigger(client->client_info_, client->client_peername_);
|
||||||
ESP_LOGV(TAG, "Remove connection %s", client->client_info_.c_str());
|
ESP_LOGV(TAG, "Remove connection %s", client->client_info_.c_str());
|
||||||
|
|
||||||
@@ -191,13 +197,7 @@ void APIServer::loop() {
|
|||||||
if (this->clients_.empty() && this->reboot_timeout_ != 0) {
|
if (this->clients_.empty() && this->reboot_timeout_ != 0) {
|
||||||
this->schedule_reboot_timeout_();
|
this->schedule_reboot_timeout_();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't increment client_index since we need to process the swapped element
|
// Don't increment client_index since we need to process the swapped element
|
||||||
} else {
|
|
||||||
// Network is connected, process the client
|
|
||||||
client->loop();
|
|
||||||
client_index++; // Move to next client
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user