picloud ping and fix big bugs

This commit is contained in:
2021-08-19 18:13:05 +03:00
parent f5af8a1da9
commit 4c0530d89a
13 changed files with 58 additions and 30 deletions

View File

@@ -7,6 +7,8 @@ CloudServer::CloudServer(DispatcherClient * c, const PIByteArray & sname) : serv
DispatcherClient * cl = index_clients.value(id, nullptr);
if (cl) cl->sendData(ba);
}));
CONNECTL(c, pingReceived, [this]() {last_ping.reset();});
last_ping.reset();
}
@@ -23,6 +25,7 @@ PIByteArray CloudServer::serverUUID() const {
void CloudServer::addClient(DispatcherClient * c) {
last_ping.reset();
clients << c;
index_clients.insert(c->clientId(), c);
c->sendConnected(1);
@@ -37,6 +40,7 @@ void CloudServer::addClient(DispatcherClient * c) {
void CloudServer::removeClient(DispatcherClient * c) {
last_ping.reset();
clients.removeOne(c);
index_clients.removeOne(c->clientId());
server->sendDisconnected(c->clientId());
@@ -48,6 +52,11 @@ PIVector<DispatcherClient *> CloudServer::getClients() {
}
double CloudServer::lastPing() {
return last_ping.elapsed_s();
}
void CloudServer::printStatus() {
piCout << " " << "Clients for" << server->address() << server_uuid.toHex() << ":";
for (auto c: clients) {