HttpClient.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-02-23 09:31:32
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-08-02 16:23:49
  8. */
  9. #ifndef __HTTPCLIENT_H_
  10. #define __HTTPCLIENT_H_
  11. #include <iostream>
  12. #include <time.h>
  13. #include <ctime>
  14. #include "Util/logger.h"
  15. #include "Util/NoticeCenter.h"
  16. #include "Poller/EventPoller.h"
  17. #include "Util/SqlPool.h"
  18. #include "Network/TcpClient.h"
  19. #include "Poller/Timer.h"
  20. #include "TCPClient.hpp"
  21. #include <httplib.h>
  22. #include "Notices.h"
  23. #include "md5.h"
  24. // dataType
  25. #include "NettyHttpResultMsg.h"
  26. #include "NettyHttpToken.h"
  27. #include "NettyHttpNull.h"
  28. #include "NettyExpelDevInfo.h"
  29. #include "NettyHttpDicCode.h"
  30. using namespace std;
  31. namespace gsd{
  32. class HttpClient
  33. {
  34. private:
  35. // 用户名
  36. std::string account;
  37. std::string pwd = "sunwin20200507";
  38. // 固定16位私钥
  39. std::string privateKey = "mwWAH2eUAAHodlRt";
  40. // authToken
  41. std::string authToken = "";
  42. // refreshToken
  43. std::string refreshToken = "";
  44. public:
  45. HttpClient() {}
  46. ~HttpClient() {}
  47. /**
  48. * @description: 初始化
  49. * @param {string} account
  50. * @param {string} url
  51. * @param {int} port
  52. * @return {*}
  53. */
  54. int32_t Init(std::string account,std::string url, int port);
  55. /**
  56. * @description: 创建对象
  57. * @param {*}
  58. * @return {*}
  59. */
  60. static std::shared_ptr<HttpClient> CreateNew();
  61. /**
  62. * @description: 登录
  63. * @param {*}
  64. * @return {*}
  65. */
  66. int32_t LoginNetty();
  67. /**
  68. * @description: 判断是否获取到Token
  69. * @param {*}
  70. * @return {*}
  71. */
  72. bool alive();
  73. /**
  74. * @description: 获取时间
  75. * @param {char} *ctime
  76. * @return {*}
  77. */
  78. static void getDataTime(char *ctime);
  79. /**
  80. * @description: 获取驱鸟设备信息
  81. * @param {*}
  82. * @return {*}
  83. */
  84. int32_t getExpelInfo(std::string simCode, NettyHttpResultMsg<NettyExpelDevInfo,NettyHttpNull>& nettyHttpResultMsg);
  85. /**
  86. * @description: 获取派尔云的设备数据
  87. * @param {*}
  88. * @return {*}
  89. */
  90. int32_t getHttpDicCode(std::string dictCode,NettyHttpResultMsg<NettyHttpDicCode,NettyHttpNull>& nettyHttpResultMsg);
  91. };
  92. };
  93. #endif