2023-07-10 08:36:19 +00:00
|
|
|
#pragma once
|
|
|
|
#include "AIGCJson.hpp"
|
|
|
|
|
2023-08-15 03:01:31 +00:00
|
|
|
#define USER_REAL_PLATFORM (0)
|
|
|
|
|
2023-07-10 08:36:19 +00:00
|
|
|
class ProtocolBase {
|
|
|
|
public:
|
|
|
|
ProtocolBase() {
|
|
|
|
this->ver = 1;
|
|
|
|
this->timeStamp = static_cast<unsigned int>(time(nullptr));
|
|
|
|
this->cryptoType = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int ver;
|
|
|
|
unsigned int cryptoType;
|
|
|
|
unsigned int timeStamp;
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(ver, cryptoType, timeStamp)
|
|
|
|
|
2023-08-15 03:01:31 +00:00
|
|
|
void SetVersion(unsigned int versino) {
|
|
|
|
this->ver = versino;
|
2023-07-10 08:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetTimeStamp(unsigned int ts) {
|
|
|
|
this->timeStamp = ts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCryptoType(unsigned int crypto) {
|
2023-08-15 03:01:31 +00:00
|
|
|
this->cryptoType = crypto;
|
2023-07-10 08:36:19 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
class ResponseStatus {
|
|
|
|
public:
|
|
|
|
int errCode;
|
|
|
|
std::string errMessage;
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(errCode, errMessage)
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T> class ProtocolRequest : public ProtocolBase {
|
2023-07-10 08:36:19 +00:00
|
|
|
public:
|
|
|
|
T msgContent;
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(msgContent)
|
|
|
|
AIGC_JSON_HELPER_BASE((ProtocolBase *)this)
|
|
|
|
};
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
template<class T> class ProtocolResponse : public ProtocolBase {
|
2023-07-10 08:36:19 +00:00
|
|
|
public:
|
|
|
|
int code;
|
|
|
|
T msgContent;
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(code, msgContent)
|
|
|
|
AIGC_JSON_HELPER_BASE((ProtocolBase *)this)
|
|
|
|
};
|