50 lines
983 B
C++
50 lines
983 B
C++
#include "cloudserver.h"
|
|
|
|
CloudServer::CloudServer(DispatcherClient * c, const PIString & sname) : server(c) {
|
|
setName(sname);
|
|
server_name = sname;
|
|
}
|
|
|
|
|
|
CloudServer::~CloudServer() {
|
|
for (auto c :clients) {
|
|
c->close();
|
|
}
|
|
}
|
|
|
|
|
|
PIString CloudServer::serverName() const {
|
|
return server_name;
|
|
}
|
|
|
|
|
|
void CloudServer::addClient(DispatcherClient * c) {
|
|
clients << c;
|
|
index_clients.insert(c->clientId(), c);
|
|
c->sendConnected();
|
|
}
|
|
|
|
|
|
void CloudServer::removeClient(DispatcherClient * c) {
|
|
clients.removeOne(c);
|
|
index_clients.removeOne(c->clientId());
|
|
}
|
|
|
|
|
|
PIVector<DispatcherClient *> CloudServer::getClients() {
|
|
return clients;
|
|
}
|
|
|
|
|
|
void CloudServer::printStatus() {
|
|
piCout << " " << "Clients for" << server->address() << server_name << ":";
|
|
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());
|
|
}
|
|
}
|
|
|