cloud fix ... ((

This commit is contained in:
2024-03-25 21:17:05 +03:00
parent 02a9bfb76f
commit 0d585cfebf
5 changed files with 24 additions and 11 deletions

View File

@@ -3,14 +3,14 @@
CloudServer::CloudServer(DispatcherClient * c, const PIByteArray & sname): server(c) {
setName(sname.toHex());
server_uuid = sname;
CONNECTL(c, dataReadedServer, ([this](uint id, PIByteArray & ba) {
last_ping.reset();
mutex_clients.lock();
DispatcherClient * cl = index_clients.value(id, nullptr);
mutex_clients.unlock();
if (cl) cl->sendData(ba);
}));
CONNECTL(c, pingReceived, [this]() { last_ping.reset(); });
connects << CONNECTL(c, dataReadedServer, ([this](uint id, PIByteArray & ba) {
last_ping.reset();
mutex_clients.lock();
DispatcherClient * cl = index_clients.value(id, nullptr);
mutex_clients.unlock();
if (cl) cl->sendData(ba);
}));
connects << CONNECTL(c, pingReceived, [this]() { last_ping.reset(); });
last_ping.reset();
}
@@ -19,6 +19,8 @@ CloudServer::~CloudServer() {
for (auto c: clients) {
c->close();
}
for (auto & c: connects)
c.disconnect();
}
@@ -70,6 +72,11 @@ void CloudServer::close() {
}
void CloudServer::stop() {
server->stop();
}
void CloudServer::printStatus() {
PIMutexLocker locker(mutex_clients);
piCout << " "