httpthreadnum1.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef HTTPTHREADNUM1_H
  2. #define HTTPTHREADNUM1_H
  3. #include "HttpClient.h"
  4. #include "httpThreadNum1_global.h"
  5. #include <QThread>
  6. #include <QMap>
  7. #include <QMutex>
  8. typedef void (*TOnDevInfoChange)(const int &iType,void *pStruct); //定义回调
  9. extern TOnDevInfoChange callbackDevInfoChange; //全局回调函数变量
  10. extern int EC_SetOnDevInfoChange(TOnDevInfoChange onChange,void* pUser); //设置回调
  11. //做一个线程的类
  12. class HTTPTHREADNUM1_EXPORT HttpThreadNum1:public QThread
  13. {
  14. Q_OBJECT
  15. public:
  16. //构造函数里创建了请求地址列表m_HTN1MapApi和待请求数据队列m_listStructReady
  17. HttpThreadNum1();
  18. void init();
  19. void postData(int iType,void *structData); //接口1
  20. //扩展
  21. void setToken(QString qsTok);
  22. protected:
  23. //线程启动的时候调用
  24. void run();
  25. private:
  26. //单层容器
  27. QMap<int,QString> m_HTN1MapApi; //请求地址列表
  28. QString m_qsServiceUrl= "http://192.168.131.23:9000"; //处理线程数量
  29. //定义一个QMap双层容器,存储请求的数据队列
  30. QMap<int,QList<QVariant>> m_listStructReady;
  31. QMutex m_QMutex;
  32. public:
  33. void priPostData(int iType,QVariant structData,void* voidPointer);
  34. signals:
  35. void sig_result(int iType,QVariant); //接口2
  36. };
  37. #endif // HTTPTHREADNUM1_H