some fix for PICloudServer
This commit is contained in:
@@ -29,7 +29,9 @@ PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode)
|
||||
CONNECTL(ð, connected, [this](){opened_ = true; piCoutObj << "connected" << ð tcp.sendStart();});
|
||||
CONNECTL(ð, disconnected, [this](bool){
|
||||
piCoutObj << "disconnected" << ð
|
||||
eth.stop();
|
||||
for (auto c : clients_) {
|
||||
delete c;
|
||||
}
|
||||
opened_ = false;
|
||||
ping_timer.stop(false);
|
||||
piMSleep(100);
|
||||
@@ -88,6 +90,7 @@ bool PICloudServer::closeDevice() {
|
||||
for (auto c : clients_) {
|
||||
delete c;
|
||||
}
|
||||
clients_.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -220,6 +223,7 @@ void PICloudServer::_readed(PIByteArray & ba) {
|
||||
Client * oc = index_clients.value(id, nullptr);
|
||||
clients_mutex.unlock();
|
||||
if (oc) {
|
||||
oc->stopAndWait();
|
||||
//oc->is_connected = false;
|
||||
//oc->close();
|
||||
delete oc;
|
||||
@@ -245,8 +249,7 @@ void PICloudServer::clientDeleted(PIObject * o) {
|
||||
clients_mutex.lock();
|
||||
clients_.removeOne(c);
|
||||
auto it = index_clients.makeIterator();
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
while (it.next()) {
|
||||
if (it.value() == c) {
|
||||
index_clients.remove(it.key());
|
||||
break;
|
||||
|
||||
@@ -52,10 +52,9 @@ int main(int argc, char * argv[]) {
|
||||
}));
|
||||
CONNECTL(cl, closed, ([&clients, cl](){
|
||||
piCout << "[Server] client closed ..." << cl;
|
||||
cl->stop();
|
||||
cl->stopAndWait();
|
||||
clients.removeAll(cl);
|
||||
piCout << "[Server] client closed ok" << cl;
|
||||
//cl->deleteLater();
|
||||
}));
|
||||
cl->startThreadedRead();
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user