HttpClient.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2021-11-03 14:08:44
  6. * @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
  7. * @LastEditTime: 2022-07-10 18:05:12
  8. */
  9. #pragma once
  10. #include <iostream>
  11. #include <time.h>
  12. #include <ctime>
  13. #include "Util/logger.h"
  14. #include "Util/NoticeCenter.h"
  15. #include "Util/SqlPool.h"
  16. #include "Network/TcpClient.h"
  17. #include "Poller/Timer.h"
  18. #include "inifile.h"
  19. #include "Notices.h"
  20. #include "md5.h"
  21. #include "NettyHttpResultMsg.h"
  22. #include "NettyHttpToken.h"
  23. #include "NettyHttpNull.h"
  24. #include "NettyHttpCarInfo.h"
  25. #include "NettyHttpPeakValleyConfig.h"
  26. #include "NettyHttpCrowdingDegreeConfig.h"
  27. #include "NettyHttpDeviceConfig.h"
  28. #include "uuid.hpp"
  29. using namespace std;
  30. using namespace utility;
  31. namespace gsd_ds
  32. {
  33. class HttpClient
  34. {
  35. private:
  36. // 用户名
  37. std::string account;
  38. std::string pwd = "sunwin20211102";
  39. // 固定16位私钥
  40. std::string privateKey = "mwWAH2eUAAHodlRt";
  41. // authToken
  42. std::string authToken = "";
  43. // refreshToken
  44. std::string refreshToken = "";
  45. public:
  46. HttpClient();
  47. ~HttpClient();
  48. using Ptr = std::shared_ptr<HttpClient>;
  49. /**
  50. * @description: 初始化
  51. * @param {string} account
  52. * @param {string} url
  53. * @param {int} port
  54. * @return {*}
  55. */
  56. int32_t Init(std::string account,std::string url, int port);
  57. /**
  58. * @description: 创建对象
  59. * @param {*}
  60. * @return {*}
  61. */
  62. static std::shared_ptr<HttpClient> CreateNew();
  63. /**
  64. * @description: 发送Post请求
  65. * @param {*}
  66. * @return {*}
  67. */
  68. int8_t Post_Bird(std::string& json);
  69. /**
  70. * @description: 获取时间
  71. * @param {char} *ctime
  72. * @return {*}
  73. */
  74. static void getDataTime(char *ctime);
  75. /**
  76. * @description: 判断是否获取到Token
  77. * @param {*}
  78. * @return {*}
  79. */
  80. bool alive();
  81. /**
  82. * @description: 控制设备
  83. * @param {*}
  84. * @return {*}
  85. */
  86. int8_t ControlDev(std::string commandCode);
  87. };
  88. } // namespace name