NetTunnelWindows/NetTunnelSDK/include/ProtocolBase.h

56 lines
1.1 KiB
C
Raw Permalink Normal View History

#pragma once
#include "AIGCJson.hpp"
2023-08-15 03:01:31 +00:00
#define USER_REAL_PLATFORM (0)
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;
}
void SetTimeStamp(unsigned int ts) {
this->timeStamp = ts;
}
void SetCryptoType(unsigned int crypto) {
2023-08-15 03:01:31 +00:00
this->cryptoType = crypto;
}
};
class ResponseStatus {
public:
int errCode;
std::string errMessage;
AIGC_JSON_HELPER(errCode, errMessage)
};
template<class T> class ProtocolRequest : public ProtocolBase {
public:
T msgContent;
AIGC_JSON_HELPER(msgContent)
AIGC_JSON_HELPER_BASE((ProtocolBase *)this)
};
template<class T> class ProtocolResponse : public ProtocolBase {
public:
int code;
T msgContent;
AIGC_JSON_HELPER(code, msgContent)
AIGC_JSON_HELPER_BASE((ProtocolBase *)this)
};