-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudpreceiver.h
49 lines (39 loc) · 1.4 KB
/
udpreceiver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 113302+1+"SULTAN SELİM MAH"+990+483+709#7011+1+"HT11"+990+483+709
#ifndef UDPCLIENT_H
#define UDPCLIENT_H
#include "udpdef.h"
#include <QNetworkDatagram>
inline static QLoggingCategory UdpReceiverCategory("UdpReceiver");
class UdpReceiver : public QObject {
Q_OBJECT
public:
UdpReceiver(qint16 port = UDP_RECEIVE_PORT, QObject *parent = nullptr);
std::optional<Utilities::HatStructList> parse(const QByteArray &data);
// getter-setter
qint16 getPort() const;
void setPort(qint16 newPort);
signals:
void dataReceived(const QByteArray &data);
void dataReceived(QStringList hatList);
void dataReceived(Utilities::HatStructList hatList);
void dataReceived(std::optional<Utilities::HatStructList> hatList);
// void dataReceived(const std::optional<Utilities::HatStructList>& hatList);
// void dataReceived(std::optional<Utilities::HatStructList>&& hatList);
public slots:
void run(); // thread start
void start(QAbstractSocket::BindFlag flag =
QAbstractSocket::BindFlag::DefaultForPlatform);
void stop();
void readyRead();
void onSocketStateChange(QAbstractSocket::SocketState state);
void onErrorOccured();
void QtReceive();
private:
QEventLoop *m_loop;
QUdpSocket *m_socket;
qint16 m_port;
QNetworkDatagram m_datagram;
Utilities::HatBilgi hatbilgi;
QByteArray m_accumulatedData; // Accumulated data
};
#endif