qt/ledset/pcaprethread.h
2023-06-06 12:13:33 +08:00

35 lines
782 B
C++

#ifndef PCAPRETHREAD_H
#define PCAPRETHREAD_H
#include "waitingdlg.h"
#include "pcap.h"
#include <QThread>
typedef std::function<void(int, const QByteArray)> FuncIntByte;
struct PcapResp {
FuncIntByte callback;
int id;
qint64 timeout;
bool notCancelled{true};
};
class PcapReThread : public QThread {
Q_OBJECT
public:
explicit PcapReThread(pcap *pcap);
~PcapReThread();
int sendMsgNet(const byte *msg, int size, int id, qint64 timeout, FuncIntByte callback, WaitingDlg *waitingDlg = 0);
std::atomic<char> status{0};
QList<PcapResp*> resps;
std::mutex mtx;
pcap *pcap;
signals:
void onMsg(FuncIntByte callback, int code, const QByteArray data);
void onError(char *);
protected:
void run();
};
#endif // PCAPRETHREAD_H