|
|
|
|
@@ -43,22 +43,26 @@ void DispatcherServer::picoutStatus() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DispatcherServer::cleanClients() {
|
|
|
|
|
PIVector<DispatcherClient*> rm;
|
|
|
|
|
map_mutex.lock();
|
|
|
|
|
for (auto c: rmrf_clients) {
|
|
|
|
|
delete c;
|
|
|
|
|
}
|
|
|
|
|
rmrf_clients.clear();
|
|
|
|
|
for (auto c: clients) {
|
|
|
|
|
if (!index_c_servers.contains(c) && !index_c_clients.contains(c)) {
|
|
|
|
|
if (rm_clients.contains(c)) rm << c;
|
|
|
|
|
else rm_clients << c;
|
|
|
|
|
if (!rm_clients.contains(c)) rm_clients << c;
|
|
|
|
|
} else rm_clients.removeAll(c);
|
|
|
|
|
}
|
|
|
|
|
for (auto c: rm_clients) {
|
|
|
|
|
if (clients.contains(c)) rm << c;
|
|
|
|
|
if (clients.contains(c)) {
|
|
|
|
|
rmrf_clients << c;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (auto c: rmrf_clients) {
|
|
|
|
|
clients.removeAll(c);
|
|
|
|
|
rm_clients.removeAll(c);
|
|
|
|
|
}
|
|
|
|
|
map_mutex.unlock();
|
|
|
|
|
for (auto c: rm) {
|
|
|
|
|
c->close();
|
|
|
|
|
// c->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -83,6 +87,12 @@ void DispatcherServer::updateConnectionsTile(TileList * tl) {
|
|
|
|
|
}
|
|
|
|
|
tl->content << TileList::Row(c->address() + " " + role, PIScreenTypes::CellFormat());
|
|
|
|
|
}
|
|
|
|
|
for (auto c: rm_clients) {
|
|
|
|
|
tl->content << TileList::Row("[deleting]" + c->address(), PIScreenTypes::CellFormat());
|
|
|
|
|
}
|
|
|
|
|
for (auto c: rmrf_clients) {
|
|
|
|
|
tl->content << TileList::Row("[NULL]" + c->address(), PIScreenTypes::CellFormat());
|
|
|
|
|
}
|
|
|
|
|
map_mutex.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -160,35 +170,35 @@ void DispatcherServer::disconnectClient(DispatcherClient *client) {
|
|
|
|
|
}
|
|
|
|
|
piCoutObj << "remove client" << client->clientId();
|
|
|
|
|
map_mutex.lock();
|
|
|
|
|
clients.removeOne(client);
|
|
|
|
|
clients.removeAll(client);
|
|
|
|
|
rm_clients.removeAll(client);
|
|
|
|
|
CloudServer * cs = index_c_servers.value(client, nullptr);
|
|
|
|
|
if (cs) {
|
|
|
|
|
PIVector<DispatcherClient *> cscv = cs->getClients();
|
|
|
|
|
for(auto csc : cscv) {
|
|
|
|
|
clients.removeOne(csc);
|
|
|
|
|
index_c_clients.removeOne(csc);
|
|
|
|
|
clients.removeAll(csc);
|
|
|
|
|
index_c_clients.remove(csc);
|
|
|
|
|
cs->removeClient(csc);
|
|
|
|
|
csc->close();
|
|
|
|
|
csc->deleteLater();
|
|
|
|
|
rmrf_clients << csc;
|
|
|
|
|
}
|
|
|
|
|
c_servers.remove(cs->serverUUID());
|
|
|
|
|
index_c_servers.removeOne(client);
|
|
|
|
|
index_c_servers.remove(client);
|
|
|
|
|
delete cs;
|
|
|
|
|
}
|
|
|
|
|
CloudServer * cc = index_c_clients.value(client, nullptr);
|
|
|
|
|
if (cc) {
|
|
|
|
|
cc->removeClient(client);
|
|
|
|
|
index_c_clients.removeOne(client);
|
|
|
|
|
index_c_clients.remove(client);
|
|
|
|
|
}
|
|
|
|
|
client->close();
|
|
|
|
|
rmrf_clients << client;
|
|
|
|
|
map_mutex.unlock();
|
|
|
|
|
client->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DispatcherServer::newConnection(PIEthernet *cl) {
|
|
|
|
|
if (clients.size_s() >= max_connections) {
|
|
|
|
|
cl->close();
|
|
|
|
|
if (clients.size() >= max_connections) {
|
|
|
|
|
delete cl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|