picloud ping and fix big bugs
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user