QThreadHttpServer.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #define CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH 65535
  3. #include "httplib.h"
  4. #include <QThread>
  5. #include <QMutex>
  6. #include "json/json.h"
  7. //#include "zkthttpserverlib_global.h"
  8. using namespace httplib;
  9. class QThreadHttpServer : public QThread
  10. {
  11. Q_OBJECT
  12. public:
  13. QThreadHttpServer(QObject *parent);
  14. ~QThreadHttpServer();
  15. void InitHttpServer();
  16. void run();
  17. static std::string logData(const Request& req, const Response& res);
  18. void StopThread();
  19. void setIPPost(QString strIp,int nServerPost);
  20. //初始化控制
  21. static void InitLink(const Request& req, Response& res);
  22. static QString initOptions(QString strSN,QString PushOptionsFlag);
  23. //处理上传数据
  24. static void RtData(const Request& req, Response& res);
  25. static void AddLogJson(std::string strRequest, std::string strResponse, std::string nAPIID, bool bStatus,bool ServerData=false);
  26. //void setCallBackData(void* pWND, UserLoginCallBack pCallback);
  27. //获取所有设备状态
  28. static void SendAllEqpmtData(Json::Value& pJson);
  29. //设置设备控制
  30. static void SetEqpmtData(Json::Value& InJson);
  31. //设置故障
  32. static void SetEqpmtFault(Json::Value& InJson);
  33. //获取子系统设备状态
  34. static void SendAllSystemData(Json::Value& pJson);
  35. //课程开启
  36. static void SetSystemRun(Json::Value& pJson);
  37. //课程结束
  38. static void SetSystemStop();
  39. //获取设备故障列表
  40. static void GetEqpmtFault(std::string strEqpmt, Json::Value& pJson);
  41. signals:
  42. void signal_LoginData(QString strID);
  43. private:
  44. //服务器类
  45. Server* svr;
  46. //服务器位置信息
  47. QString m_strServerIP;
  48. int m_nServerPost;
  49. static void* pFunWnd;
  50. //static UserLoginCallBack pFunCtrl;
  51. QMutex pInitMutex;
  52. };