123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /*
- * @Description:
- * @Version: 1.0
- * @Autor: lishengyin
- * @Date: 2022-02-23 09:31:32
- * @LastEditors: Your Name lishengyin@sz-sunwin.com
- * @LastEditTime: 2022-09-04 21:32:43
- */
- #ifndef __HTTPCLIENT_H_
- #define __HTTPCLIENT_H_
- #include <iostream>
- #include <time.h>
- #include <ctime>
- #include "Util/logger.h"
- #include "Util/NoticeCenter.h"
- #include "Poller/EventPoller.h"
- #include "Util/SqlPool.h"
- #include "Network/TcpClient.h"
- #include "Poller/Timer.h"
- #include "TCPClient.hpp"
- #include <httplib.h>
- #include "Notices.h"
- #include "md5.h"
- // dataType
- #include "NettyHttpResultMsg.h"
- #include "NettyHttpToken.h"
- #include "NettyHttpNull.h"
- #include "NettyExpelDevInfo.h"
- #include "NettyHttpDicCode.h"
- #include "HttpNull.hpp"
- #include "HttpResultMsg.hpp"
- #include "HttpToken.hpp"
- #include "UtilBase.hpp"
- #include "config.hpp"
- using namespace std;
- namespace gsd{
-
- class HttpClient: public enable_shared_from_this<HttpClient>, public ModuleBase
- {
- private:
- // 用户名
- std::string account;
- std::string pwd = "sunwin20200507";
- // 固定16位私钥
- std::string privateKey = "mwWAH2eUAAHodlRt";
- // authToken
- std::string authToken = "";
- // refreshToken
- std::string refreshToken = "";
- public:
- HttpClient() {}
- ~HttpClient() {}
- /**
- * @description: Init
- * @return {*}
- */
- virtual bool Init(){
- return true;
- }
- /**
- * @description: Destroy
- * @return {*}
- */
- virtual void Destroy(){
- }
- /**
- * @description: 初始化
- * @param {string} account
- * @param {string} url
- * @param {int} port
- * @return {*}
- */
- int32_t Init(std::string account,std::string url, int port);
- /**
- * @description: 创建对象
- * @param {*}
- * @return {*}
- */
- static std::shared_ptr<HttpClient> CreateNew();
- /**
- * @description: 登录
- * @param {*}
- * @return {*}
- */
- int32_t LoginNetty();
- /**
- * @description: 判断是否获取到Token
- * @param {*}
- * @return {*}
- */
- bool alive();
- /**
- * @description: 获取时间
- * @param {char} *ctime
- * @return {*}
- */
- static void getDataTime(char *ctime);
- /**
- * @description: 获取驱鸟设备信息
- * @param {*}
- * @return {*}
- */
- int32_t getExpelInfo(std::string simCode, NettyHttpResultMsg<NettyExpelDevInfo,NettyHttpNull>& nettyHttpResultMsg);
- /**
- * @description: 获取派尔云的设备数据
- * @param {*}
- * @return {*}
- */
- int32_t getHttpDicCode(std::string dictCode,NettyHttpResultMsg<NettyHttpDicCode,NettyHttpNull>& nettyHttpResultMsg);
- /**
- * @description: 送入判定器
- * @return {*}
- */
- std::pair<bool, std::string> getCheck(std::string& ImageBase64, std::string& datas);
- };
- };
- #endif
|