culturered_client/PhotoVideoPlayer/NetClient.h
2024-09-07 11:34:44 +08:00

31 lines
574 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();
bool WriteMessage(const QString& cmd);
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;
};