heartbeat: add basic code.

This commit is contained in:
2025-06-25 17:06:30 +08:00
parent 06bf31e8bd
commit c7b15694b9
5 changed files with 138 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ public:
void Disconnect();
bool Send(QSharedPointer<FrameBuffer> frame);
bool Send(const char* data, qint64 len);
bool IsConnect();
template <typename T> bool Send(const T& info, FrameBufferType type, const QString& tid)
{
auto f = GetBuffer<T>(info, type, tid);
@@ -104,6 +105,7 @@ public:
LocalFile localFile_;
};
// Socket Worker Thread
class SocketWorker : public QThread
{
Q_OBJECT
@@ -119,4 +121,44 @@ private:
ClientCore* core_{};
};
// HeatBeat to Server
class HeatBeat : public QThread
{
Q_OBJECT
public:
HeatBeat(ClientCore* core, QObject* parent = nullptr);
~HeatBeat() override;
public:
void Stop();
protected:
void run() override;
private:
bool isRun_{false};
ClientCore* core_{};
};
// judge send client is alive or not when downloading
class TransBeat : public QThread
{
Q_OBJECT
public:
TransBeat(ClientCore* core, QObject* parent = nullptr);
~TransBeat() override;
public:
void Stop();
protected:
void run() override;
private:
bool isRun_{false};
ClientCore* core_{};
};
#endif // CLIENTCORE_H