PICloud disconnect
This commit is contained in:
5
main.cpp
5
main.cpp
@@ -41,6 +41,11 @@ int main(int argc, char * argv[]) {
|
||||
piCout << "[Server] data from" << cl << ":" << str;
|
||||
if (str == "ping") cl->write(PIString("pong").toByteArray());
|
||||
}));
|
||||
CONNECTL(cl, closed, ([&clients, cl](){
|
||||
cl->stop();
|
||||
clients.removeAll(cl);
|
||||
cl->deleteLater();
|
||||
}));
|
||||
cl->startThreadedRead();
|
||||
}));
|
||||
if (cli.hasArgument("name")) s.setServerName(cli.argumentValue("name"));
|
||||
|
||||
@@ -39,6 +39,7 @@ void CloudServer::addClient(DispatcherClient * c) {
|
||||
void CloudServer::removeClient(DispatcherClient * c) {
|
||||
clients.removeOne(c);
|
||||
index_clients.removeOne(c->clientId());
|
||||
server->sendDisconnected(c->clientId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,11 @@ void DispatcherClient::sendConnected(uint client_id) {
|
||||
}
|
||||
|
||||
|
||||
void DispatcherClient::sendDisconnected(uint client_id) {
|
||||
tcp.sendDisconnected(client_id);
|
||||
}
|
||||
|
||||
|
||||
void DispatcherClient::sendData(const PIByteArray & data) {
|
||||
if (tcp.role() == PICloud::TCP::Client) tcp.sendData(data);
|
||||
else piCoutObj << "error sendData, invalid role";
|
||||
|
||||
@@ -14,6 +14,7 @@ public:
|
||||
void start();
|
||||
void close();
|
||||
void sendConnected(uint client_id);
|
||||
void sendDisconnected(uint client_id);
|
||||
void sendData(const PIByteArray & data);
|
||||
void sendDataToClient(const PIByteArray & data, uint client_id);
|
||||
void authorise(bool ok);
|
||||
|
||||
Reference in New Issue
Block a user