NetTunnelWindows/NetTunnelSDK/ProtocolBase.h

54 lines
1.1 KiB
C++

#pragma once
#include "AIGCJson.hpp"
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)
void SetVersion(unsigned int ver) {
this->ver = ver;
}
void SetTimeStamp(unsigned int ts) {
this->timeStamp = ts;
}
void SetCryptoType(unsigned int crypto) {
this->cryptoType = cryptoType;
}
};
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)
};