code format
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
#include "cloudserver.h"
|
||||
|
||||
CloudServer::CloudServer(DispatcherClient * c, const PIByteArray & sname) : server(c) {
|
||||
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();});
|
||||
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(); });
|
||||
last_ping.reset();
|
||||
}
|
||||
|
||||
|
||||
CloudServer::~CloudServer() {
|
||||
for (auto c :clients) {
|
||||
for (auto c: clients) {
|
||||
c->close();
|
||||
}
|
||||
}
|
||||
@@ -36,10 +36,10 @@ void CloudServer::addClient(DispatcherClient * c) {
|
||||
mutex_clients.unlock();
|
||||
c->sendConnected(1);
|
||||
server->sendConnected(cid);
|
||||
CONNECTL(c, dataReaded, ([this, cid](PIByteArray & ba){
|
||||
// piCoutObj << c->clientId() << "dataReaded";
|
||||
server->sendDataToClient(ba, cid);
|
||||
}));
|
||||
CONNECTL(c, dataReaded, ([this, cid](PIByteArray & ba) {
|
||||
// piCoutObj << c->clientId() << "dataReaded";
|
||||
server->sendDataToClient(ba, cid);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -68,11 +68,10 @@ double CloudServer::lastPing() {
|
||||
|
||||
void CloudServer::printStatus() {
|
||||
mutex_clients.lock();
|
||||
piCout << " " << "Clients for" << server->address() << server_uuid.toHex() << ":";
|
||||
piCout << " "
|
||||
<< "Clients for" << server->address() << server_uuid.toHex() << ":";
|
||||
for (auto c: clients) {
|
||||
piCout << " " << c->address() << c->clientId();
|
||||
}
|
||||
mutex_clients.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user