cloud_dispatcher patch

This commit is contained in:
2021-09-01 22:43:40 +03:00
parent 00edfa4ef0
commit f82b6c12ee
3 changed files with 9 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ CloudServer::CloudServer(DispatcherClient * c, const PIByteArray & sname) : serv
setName(sname.toHex());
server_uuid = sname;
CONNECTL(c, dataReadedServer, ([this](uint id, PIByteArray & ba){
last_ping.reset();
DispatcherClient * cl = index_clients.value(id, nullptr);
if (cl) cl->sendData(ba);
}));

View File

@@ -6,7 +6,7 @@ DispatcherClient::DispatcherClient(PIEthernet * eth_, int id) : authorised(false
CONNECTU(&disconnect_tm, tickEvent, eth, close);
CONNECTU(&streampacker, packetReceiveEvent, this, readed);
CONNECTU(eth, disconnected, this, disconnected);
piCoutObj << "client connected" << eth->sendAddress();
piCoutObj << "client connected" << client_id << eth->sendAddress();
}

View File

@@ -56,7 +56,10 @@ void DispatcherServer::cleanClients() {
}
auto ss = c_servers.values();
for (auto c: ss) {
if (c->lastPing() > 15.0) rmrf_clients << const_cast<DispatcherClient *>(c->getConnection());
if (c->lastPing() > 15.0) {
piCout << "remove Server by ping timeout" << c->getConnection()->clientId();
rmrf_clients << const_cast<DispatcherClient *>(c->getConnection());
}
}
for (auto c: rm_clients) {
if (clients.contains(c)) {
@@ -178,12 +181,13 @@ void DispatcherServer::disconnectClient(DispatcherClient *client) {
//piCoutObj << "INVALID client" << client;
return;
}
piCoutObj << "remove client" << client->clientId();
piCoutObj << "remove" << client->clientId();
map_mutex.lock();
clients.removeAll(client);
rm_clients.removeAll(client);
CloudServer * cs = index_c_servers.value(client, nullptr);
if (cs) {
piCoutObj << "remove Server" << client->clientId();
PIVector<DispatcherClient *> cscv = cs->getClients();
for(auto csc : cscv) {
clients.removeAll(csc);
@@ -198,6 +202,7 @@ void DispatcherServer::disconnectClient(DispatcherClient *client) {
}
CloudServer * cc = index_c_clients.value(client, nullptr);
if (cc) {
piCoutObj << "remove Client" << client->clientId();
cc->removeClient(client);
index_c_clients.remove(client);
}