Compare commits

5 Commits

Author SHA1 Message Date
c7c3852747 cloud! finally fixed bug! 2024-03-25 22:40:29 +03:00
c18d0c918e 4 2024-03-25 21:45:59 +03:00
9c4fd41eef 3 2024-03-25 21:37:05 +03:00
9173dc936d 2 2024-03-25 21:34:30 +03:00
77c8681b43 1 2024-03-25 21:31:41 +03:00
2 changed files with 12 additions and 16 deletions

View File

@@ -7,21 +7,15 @@ CloudServer::CloudServer(DispatcherClient * c, const PIByteArray & sname): serve
last_ping.reset();
mutex_clients.lock();
DispatcherClient * cl = index_clients.value(id, nullptr);
mutex_clients.unlock();
if (cl) cl->sendData(ba);
mutex_clients.unlock();
}));
connects << CONNECTL(c, pingReceived, [this]() { last_ping.reset(); });
last_ping.reset();
}
CloudServer::~CloudServer() {
for (auto c: clients) {
c->close();
}
for (auto & c: connects)
c.disconnect();
}
CloudServer::~CloudServer() {}
PIByteArray CloudServer::serverUUID() const {
@@ -73,6 +67,8 @@ void CloudServer::close() {
void CloudServer::stop() {
for (auto c: clients)
c->close();
server->stop();
}

View File

@@ -45,13 +45,13 @@ void DispatcherServer::picoutStatus() {
void DispatcherServer::cleanClients() {
PIMutexLocker locker(map_mutex);
for (auto s: rmrf_servers)
s->close();
piDeleteAllAndClear(rmrf_servers);
for (auto c: rmrf_clients) {
if (!c->isPIObject()) piCout << "ACHTUNG! Non-piobject client!";
}
piDeleteAllAndClear(rmrf_clients);
for (auto s: rmrf_servers)
s->close();
piDeleteAllAndClear(rmrf_servers);
for (auto c: clients) {
if (!index_c_servers.contains(c) && !index_c_clients.contains(c)) {
if (!rm_clients.contains(c)) rm_clients << c;
@@ -75,7 +75,7 @@ void DispatcherServer::cleanClients() {
c_servers.remove(c->serverUUID());
index_c_servers.remove(c->getConnection());
rmrf_clients << const_cast<DispatcherClient *>(c->getConnection());
delete c;
rmrf_servers << c;
}
}
for (auto c: rm_clients) {
@@ -223,10 +223,10 @@ void DispatcherServer::disconnectClient(DispatcherClient * client) {
void DispatcherServer::newConnection(PIEthernet * cl) {
piCout << "DispatcherServer::newConnection" << (void *)cl;
// piCout << "DispatcherServer::newConnection" << (void *)cl;
PIMutexLocker locker(map_mutex);
if (clients.size() >= max_connections) {
piCout << "DispatcherServer::newConnection overflow" << (void *)cl;
// piCout << "DispatcherServer::newConnection overflow" << (void *)cl;
delete cl;
return;
}
@@ -237,7 +237,7 @@ void DispatcherServer::newConnection(PIEthernet * cl) {
CloudServer * cs = c_servers.value(sname, nullptr);
if (cs) {
rm_clients << c;
piCoutObj << "dublicate Server ->" << sname.toHex();
piCoutObj << "duplicate Server ->" << sname.toHex();
} else {
piCoutObj << "add new Server ->" << sname.toHex();
CloudServer * cs = new CloudServer(c, sname);
@@ -262,5 +262,5 @@ void DispatcherServer::newConnection(PIEthernet * cl) {
// piCoutObj << "add client" << client;
clients.push_back(client);
client->start();
piCout << "DispatcherServer::newConnection started" << (void *)cl;
// piCout << "DispatcherServer::newConnection started" << (void *)cl;
}