2023-04-14 18:44:28 +00:00
|
|
|
#ifndef NETWORK_H
|
|
|
|
#define NETWORK_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
|
|
|
|
class Network : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY activeChanged)
|
|
|
|
public:
|
|
|
|
static Network *globalInstance();
|
|
|
|
|
|
|
|
bool isActive() const { return m_isActive; }
|
|
|
|
void setActive(bool b);
|
|
|
|
|
|
|
|
Q_INVOKABLE QString generateUniqueId() const;
|
|
|
|
Q_INVOKABLE bool sendConversation(const QString &conversation);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void activeChanged();
|
2023-04-23 11:35:38 +00:00
|
|
|
void healthCheckFailed(int code);
|
2023-04-14 18:44:28 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
2023-04-23 11:35:38 +00:00
|
|
|
void handleHealthFinished();
|
2023-04-14 18:44:28 +00:00
|
|
|
void handleJsonUploadFinished();
|
|
|
|
|
|
|
|
private:
|
2023-04-23 11:35:38 +00:00
|
|
|
void sendHealth();
|
2023-04-14 18:44:28 +00:00
|
|
|
bool packageAndSendJson(const QString &json);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_isActive;
|
|
|
|
QString m_uniqueId;
|
|
|
|
QNetworkAccessManager m_networkManager;
|
|
|
|
QVector<QNetworkReply*> m_activeUploads;
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit Network();
|
|
|
|
~Network() {}
|
|
|
|
friend class MyNetwork;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LLM_H
|