29 lines
532 B
C++
29 lines
532 B
C++
#pragma once
|
|
|
|
#include <QUdpSocket>
|
|
#include <QNetworkAccessManager>
|
|
|
|
class NetClient : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit NetClient(QObject* param = nullptr);
|
|
~NetClient() override = default;
|
|
|
|
bool Start(quint16 port);
|
|
void Stop();
|
|
|
|
Q_SIGNALS:
|
|
void FileReady(const QString& filePath);
|
|
|
|
protected:
|
|
void OnReadyRead();
|
|
|
|
void ParseMessage(const QByteArray& message);
|
|
void DownlaodFile(const QString& fileName);
|
|
void DownloadFinish();
|
|
|
|
private:
|
|
QUdpSocket* m_udpSocket{nullptr};
|
|
QNetworkAccessManager m_manager;
|
|
}; |