summaryrefslogtreecommitdiffhomepage
path: root/tracker-udp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-udp')
-rw-r--r--tracker-udp/ftnoir_tracker_udp.cpp12
-rw-r--r--tracker-udp/ftnoir_tracker_udp.h4
2 files changed, 9 insertions, 7 deletions
diff --git a/tracker-udp/ftnoir_tracker_udp.cpp b/tracker-udp/ftnoir_tracker_udp.cpp
index b3df5e60..41aa96c2 100644
--- a/tracker-udp/ftnoir_tracker_udp.cpp
+++ b/tracker-udp/ftnoir_tracker_udp.cpp
@@ -29,9 +29,6 @@ void udp::run()
QByteArray datagram;
datagram.resize(sizeof(last_recv_pose));
- if (!sock.bind(QHostAddress::Any, quint16(s.port), QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint))
- return;
-
while (!isInterruptionRequested())
{
if (sock.hasPendingDatagrams())
@@ -69,10 +66,15 @@ void udp::run()
}
}
-void udp::start_tracker(QFrame*)
+module_status udp::start_tracker(QFrame*)
{
- start();
+ if (!sock.bind(QHostAddress::Any, quint16(s.port), QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint))
+ return error(tr("Can't bind socket -- %1").arg(sock.errorString()));
+
sock.moveToThread(this);
+ start();
+
+ return status_ok();
}
void udp::data(double *data)
diff --git a/tracker-udp/ftnoir_tracker_udp.h b/tracker-udp/ftnoir_tracker_udp.h
index 0167a005..8e8a385c 100644
--- a/tracker-udp/ftnoir_tracker_udp.h
+++ b/tracker-udp/ftnoir_tracker_udp.h
@@ -19,12 +19,12 @@ struct settings : opts {
{}
};
-class udp : public ITracker, protected QThread
+class udp : protected QThread, public ITracker
{
public:
udp();
~udp() override;
- void start_tracker(QFrame *) override;
+ module_status start_tracker(QFrame *) override;
void data(double *data) override;
protected:
void run() override;