Skip to content
Snippets Groups Projects
Commit ea3ac163 authored by calrama's avatar calrama
Browse files

Handle network disconnects

parent 7a0ee1c8
Branches master
No related tags found
No related merge requests found
...@@ -11,7 +11,10 @@ void TcpListener::acceptConnection() ...@@ -11,7 +11,10 @@ void TcpListener::acceptConnection()
while (this->hasPendingConnections()) while (this->hasPendingConnections())
{ {
QTcpSocket *socket = this->nextPendingConnection(); QTcpSocket *socket = this->nextPendingConnection();
_sockets.push_back(socket); _sockets.insert(socket);
QObject::connect(socket, &QTcpSocket::disconnected, [this, socket](){
_sockets.erase(socket);
});
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "../TrackedComponents/pose/FishPose.h" #include "../TrackedComponents/pose/FishPose.h"
#include <vector> #include <unordered_set>
#include <chrono> #include <chrono>
class TcpListener : public QTcpServer class TcpListener : public QTcpServer
...@@ -27,5 +27,5 @@ public slots: ...@@ -27,5 +27,5 @@ public slots:
std::chrono::system_clock::time_point ts); std::chrono::system_clock::time_point ts);
private: private:
std::vector<QTcpSocket *> _sockets; std::unordered_set<QTcpSocket *> _sockets;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment