PIClout data send and receive test

This commit is contained in:
2021-04-07 18:03:28 +03:00
parent 21e00e7176
commit bf63b0e9f3
6 changed files with 115 additions and 36 deletions

View File

@@ -3,6 +3,10 @@
CloudServer::CloudServer(DispatcherClient * c, const PIString & sname) : server(c) {
setName(sname);
server_name = sname;
CONNECTL(c, dataReadedServer, ([this](uint id, PIByteArray & ba){
DispatcherClient * cl = index_clients.value(id, nullptr);
if (cl) cl->sendData(ba);
}));
}
@@ -21,7 +25,14 @@ PIString CloudServer::serverName() const {
void CloudServer::addClient(DispatcherClient * c) {
clients << c;
index_clients.insert(c->clientId(), c);
c->sendConnected();
c->sendConnected(1);
server->sendConnected(c->clientId());
CONNECTL(c, dataReaded, ([this, c](PIByteArray & ba){
// piCoutObj << c->clientId() << "dataReaded";
if (clients.contains(c)) {
server->sendDataToClient(ba, c->clientId());
}
}));
}
@@ -41,9 +52,10 @@ void CloudServer::printStatus() {
for (auto c: clients) {
piCout << " " << c->address() << c->clientId();
}
for (auto c: clients) {
c->sendData(PIByteArray::fromHex("000000"));
server->sendDataToClient(PIByteArray::fromHex("000000"), c->clientId());
}
// for (auto c: clients) {
// c->sendData(PIByteArray::fromHex("000000"));
// server->sendDataToClient(PIByteArray::fromHex("000000"), c->clientId());
// }
}