mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 21:21:24 +01:00
more diag and inUse tests
This commit is contained in:
parent
198d762a21
commit
041a6534da
@ -80,16 +80,15 @@ public:
|
|||||||
};
|
};
|
||||||
bool recycle(WiFiClient c) {
|
bool recycle(WiFiClient c) {
|
||||||
|
|
||||||
if (inUse == true) return false;
|
if (wifi == c) {
|
||||||
|
if (inUse == true)
|
||||||
// return false here until we have
|
DIAG(F("WARNING: Duplicate"));
|
||||||
// implemented a LRU timer
|
else
|
||||||
// if (LRU too recent) return false;
|
DIAG(F("Returning"));
|
||||||
|
inUse = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wifi = c;
|
|
||||||
inUse = true;
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
WiFiClient wifi;
|
WiFiClient wifi;
|
||||||
bool inUse = true;
|
bool inUse = true;
|
||||||
@ -299,14 +298,14 @@ void WifiESP::loop() {
|
|||||||
while (client = server->available()) {
|
while (client = server->available()) {
|
||||||
for (clientId=0; clientId<clients.size(); clientId++){
|
for (clientId=0; clientId<clients.size(); clientId++){
|
||||||
if (clients[clientId].recycle(client)) {
|
if (clients[clientId].recycle(client)) {
|
||||||
DIAG(F("Recycle client %d %s"), clientId, client.remoteIP().toString().c_str());
|
DIAG(F("Recycle client %d %s:%d"), clientId, client.remoteIP().toString().c_str(),client.remotePort());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clientId>=clients.size()) {
|
if (clientId>=clients.size()) {
|
||||||
NetworkClient nc(client);
|
NetworkClient nc(client);
|
||||||
clients.push_back(nc);
|
clients.push_back(nc);
|
||||||
DIAG(F("New client %d, %s"), clientId, client.remoteIP().toString().c_str());
|
DIAG(F("New client %d, %s:%d"), clientId, client.remoteIP().toString().c_str(),client.remotePort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user