Skip to content

Commit 1db2b64

Browse files
committed
delete:logout protocol support
modify:heart protocol send support
1 parent 8fea01f commit 1db2b64

File tree

5 files changed

+16
-151
lines changed

5 files changed

+16
-151
lines changed

XEngine_Module/XEngine_Verification/Verification_Define.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,30 +1030,6 @@ extern "C" bool Verification_XAuthNet_GetAuth();
10301030
*********************************************************************/
10311031
extern "C" bool Verification_XAuthNet_Login(LPCXSTR lpszUser, LPCXSTR lpszPass, LPCXSTR lpszHWCode = NULL, XSHOT nDYCode = 0, XNETHANDLE xhToken = 0, XLONG dwCryption = 0, VERIFICATION_USERINFO* pSt_UserInfo = NULL);
10321032
/********************************************************************
1033-
函数名称:Verification_XAuthNet_Logout
1034-
函数功能:用户登出协议
1035-
参数.一:lpszUser
1036-
In/Out:In
1037-
类型:常量字符指针
1038-
可空:N
1039-
意思:输入用户名
1040-
参数.二:lpszPass
1041-
In/Out:In
1042-
类型:常量字符指针
1043-
可空:N
1044-
意思:输入密码
1045-
参数.三:dwCryption
1046-
In/Out:In
1047-
类型:整数型
1048-
可空:Y
1049-
意思:密码加密方法
1050-
返回值
1051-
类型:逻辑型
1052-
意思:是否成功
1053-
备注:
1054-
*********************************************************************/
1055-
extern "C" bool Verification_XAuthNet_Logout(LPCXSTR lpszUser, LPCXSTR lpszPass, XLONG dwCryption = 0);
1056-
/********************************************************************
10571033
函数名称:Verification_XAuthNet_GetToken
10581034
函数功能:获取当前的令牌句柄
10591035
参数.一:pxhToken

XEngine_Module/XEngine_Verification/Verification_XAuth/Verification_XAuthNet.cpp

Lines changed: 16 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -861,126 +861,6 @@ bool CVerification_XAuthNet::Verification_XAuthNet_Login(LPCXSTR lpszUser, LPCXS
861861
return true;
862862
}
863863
/********************************************************************
864-
函数名称:Verification_XAuthNet_Logout
865-
函数功能:用户登出协议
866-
参数.一:lpszUser
867-
In/Out:In
868-
类型:常量字符指针
869-
可空:N
870-
意思:输入用户名
871-
参数.二:lpszPass
872-
In/Out:In
873-
类型:常量字符指针
874-
可空:N
875-
意思:输入密码
876-
参数.三:dwCryption
877-
In/Out:In
878-
类型:整数型
879-
可空:Y
880-
意思:密码加密方法
881-
返回值
882-
类型:逻辑型
883-
意思:是否成功
884-
备注:
885-
*********************************************************************/
886-
bool CVerification_XAuthNet::Verification_XAuthNet_Logout(LPCXSTR lpszUser, LPCXSTR lpszPass, XLONG dwCryption /* = 0 */)
887-
{
888-
Verification_IsErrorOccur = false;
889-
890-
if ((NULL == lpszUser) || (NULL == lpszPass))
891-
{
892-
Verification_IsErrorOccur = true;
893-
Verification_dwErrorCode = ERROR_XENGINE_MODULE_VERIFICATION_XAUTH_PARAMENT;
894-
return false;
895-
}
896-
XCHAR tszMsgBuffer[2048] = {};
897-
XENGINE_PROTOCOLHDR st_ProtocolHdr = {};
898-
XENGINE_PROTOCOL_USERAUTHEX st_AuthUser = {};
899-
//协议头
900-
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
901-
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
902-
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REQLOGOUT;
903-
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_USERAUTHEX);
904-
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
905-
906-
#ifdef _MSC_BUILD
907-
st_AuthUser.enDeviceType = ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS;
908-
#elif __linux__
909-
st_AuthUser.enDeviceType = ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_LINUX;
910-
#else
911-
st_AuthUser.enDeviceType = ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_MACOS;
912-
#endif
913-
_tcsxcpy(st_AuthUser.tszUserName, lpszUser);
914-
915-
if (dwCryption > 0)
916-
{
917-
int nPLen = _tcsxlen(lpszPass);
918-
XBYTE byMD5Buffer[XPATH_MAX] = {};
919-
Cryption_Api_Digest(lpszPass, byMD5Buffer, &nPLen, false, dwCryption);
920-
BaseLib_String_StrToHex((LPCXSTR)byMD5Buffer, nPLen, st_AuthUser.tszUserPass);
921-
}
922-
else
923-
{
924-
_tcsxcpy(st_AuthUser.tszUserPass, lpszPass);
925-
}
926-
//是否加密
927-
int nMsgLen = 0;
928-
if (_tcsxlen(tszPassStr) > 0)
929-
{
930-
XCHAR tszCodecBuffer[2048] = {};
931-
932-
st_ProtocolHdr.wCrypto = ENUM_XENGINE_PROTOCOLHDR_CRYPTO_TYPE_XCRYPT;
933-
Cryption_XCrypto_Encoder((LPCXSTR)&st_AuthUser, (int*)&st_ProtocolHdr.unPacketSize, (XBYTE*)tszCodecBuffer, tszPassStr);
934-
935-
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
936-
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), tszCodecBuffer, st_ProtocolHdr.unPacketSize);
937-
938-
nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
939-
}
940-
else
941-
{
942-
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
943-
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), &st_AuthUser, st_ProtocolHdr.unPacketSize);
944-
945-
nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_USERAUTHEX);
946-
}
947-
//发送数据
948-
if (!XClient_TCPSelect_SendMsg(m_hSocket, tszMsgBuffer, nMsgLen))
949-
{
950-
Verification_IsErrorOccur = true;
951-
Verification_dwErrorCode = XClient_GetLastError();
952-
return false;
953-
}
954-
955-
nMsgLen = 0;
956-
XCHAR* ptszMsgBuffer = NULL;
957-
st_ProtocolHdr = {};
958-
//接受数据
959-
if (!XClient_TCPSelect_RecvPkt(m_hSocket, &ptszMsgBuffer, &nMsgLen, &st_ProtocolHdr))
960-
{
961-
Verification_IsErrorOccur = true;
962-
Verification_dwErrorCode = XClient_GetLastError();
963-
return false;
964-
}
965-
BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
966-
//判断是否登录协议
967-
if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REQLOGOUT != st_ProtocolHdr.unOperatorCode)
968-
{
969-
Verification_IsErrorOccur = true;
970-
Verification_dwErrorCode = ERROR_XENGINE_MODULE_VERIFICATION_XAUTH_CODE;
971-
return false;
972-
}
973-
//登录失败,错误码
974-
if (0 != st_ProtocolHdr.wReserve)
975-
{
976-
Verification_IsErrorOccur = true;
977-
Verification_dwErrorCode = st_ProtocolHdr.wReserve;
978-
return false;
979-
}
980-
Verification_XAuthNet_Close();
981-
return true;
982-
}
983-
/********************************************************************
984864
函数名称:Verification_XAuthNet_GetToken
985865
函数功能:获取当前的令牌句柄
986866
参数.一:pxhToken
@@ -1098,13 +978,28 @@ bool CVerification_XAuthNet::Verification_XAuthNet_HTTPRequest(LPCXSTR lpszURLAd
1098978
XHTHREAD XCALLBACK CVerification_XAuthNet::Verification_XAuthNet_Thread(XPVOID lParam)
1099979
{
1100980
CVerification_XAuthNet* pClass_This = (CVerification_XAuthNet*)lParam;
981+
XENGINE_PROTOCOLHDR st_ProtocolHeart = {};
982+
983+
st_ProtocolHeart.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
984+
st_ProtocolHeart.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
985+
st_ProtocolHeart.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_HB_SYN;
986+
st_ProtocolHeart.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
1101987

1102988
while (pClass_This->m_bRun)
1103989
{
990+
//发送心跳
991+
if (!XClient_TCPSelect_SendMsg(pClass_This->m_hSocket, (LPCXSTR)&st_ProtocolHeart, sizeof(XENGINE_PROTOCOLHDR)))
992+
{
993+
//心跳失败
994+
pClass_This->m_bRun = false;
995+
pClass_This->m_bLogin = false;
996+
pClass_This->m_bAuth = false;
997+
XClient_TCPSelect_Close(pClass_This->m_hSocket);
998+
break;
999+
}
11041000
int nMsgLen = 0;
11051001
XCHAR* ptszMsgBuffer = NULL;
11061002
XENGINE_PROTOCOLHDR st_ProtocolHdr = {};
1107-
11081003
if (!XClient_TCPSelect_RecvPkt(pClass_This->m_hSocket, &ptszMsgBuffer, &nMsgLen, &st_ProtocolHdr))
11091004
{
11101005
XLONG dwRet = XClient_GetLastError();

XEngine_Module/XEngine_Verification/Verification_XAuth/Verification_XAuthNet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class CVerification_XAuthNet
3434
bool Verification_XAuthNet_Close();
3535
bool Verification_XAuthNet_GetAuth();
3636
bool Verification_XAuthNet_Login(LPCXSTR lpszUser, LPCXSTR lpszPass, LPCXSTR lpszHWCode = NULL, XSHOT nDYCode = 0, XNETHANDLE xhToken = 0, XLONG dwCryption = 0, VERIFICATION_USERINFO* pSt_UserInfo = NULL);
37-
bool Verification_XAuthNet_Logout(LPCXSTR lpszUser, LPCXSTR lpszPass, XLONG dwCryption = 0);
3837
bool Verification_XAuthNet_GetToken(XNETHANDLE* pxhToken);
3938
protected:
4039
bool Verification_XAuthNet_HTTPRequest(LPCXSTR lpszURLAddr, XCHAR* ptszMSGBuffer, int* pInt_MSGLen, LPCXSTR lpszMSGBuffer = NULL, LPCXSTR lpszPassword = NULL);

XEngine_Module/XEngine_Verification/XEngine_Verification.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ EXPORTS
3939
Verification_XAuthNet_Close
4040
Verification_XAuthNet_GetAuth
4141
Verification_XAuthNet_Login
42-
Verification_XAuthNet_Logout
4342
Verification_XAuthNet_GetToken

XEngine_Module/XEngine_Verification/pch.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ extern "C" bool Verification_XAuthNet_Login(LPCXSTR lpszUser, LPCXSTR lpszPass,
177177
{
178178
return m_XAuthNetVerification.Verification_XAuthNet_Login(lpszUser, lpszPass, lpszHWCode, nDYCode, xhToken, dwCryption, pSt_UserInfo);
179179
}
180-
extern "C" bool Verification_XAuthNet_Logout(LPCXSTR lpszUser, LPCXSTR lpszPass, XLONG dwCryption)
181-
{
182-
return m_XAuthNetVerification.Verification_XAuthNet_Logout(lpszUser, lpszPass, dwCryption);
183-
}
184180
extern "C" bool Verification_XAuthNet_GetToken(XNETHANDLE* pxhToken)
185181
{
186182
return m_XAuthNetVerification.Verification_XAuthNet_GetToken(pxhToken);

0 commit comments

Comments
 (0)