PIClout data send and receive test
This commit is contained in:
@@ -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());
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user