Skip to content

Commit aa5fc4c

Browse files
committed
update:example
1 parent 3cb5c59 commit aa5fc4c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

XEngine_Apps/Authorize_APPClient/Authorize_APPClient.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ bool bRun = true;
4040
bool bLogin = true;
4141
bool bTimeOut = true;
4242
bool bEncrypto = false;
43+
bool bHeart = true;
4344
XNETHANDLE xhToken = 0;
4445
int nDYCode = 0;
4546

@@ -53,6 +54,7 @@ __int64x nIDNumber = 511025111111111111;
5354

5455
XHTHREAD AuthClient_Thread()
5556
{
57+
time_t nTimeStart = time(NULL);
5658
while (bRun)
5759
{
5860
int nMsgLen = 0;
@@ -98,6 +100,22 @@ XHTHREAD AuthClient_Thread()
98100
printf(_X("不明白的类型\n"));
99101
}
100102
}
103+
if (bHeart)
104+
{
105+
time_t nTimeEnd = time(NULL);
106+
if ((nTimeEnd - nTimeStart) > 2)
107+
{
108+
XENGINE_PROTOCOLHDR st_ProtocolHdr = {};
109+
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
110+
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_HEARTBEAT;
111+
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_HB_SYN;
112+
st_ProtocolHdr.byVersion = 1;
113+
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
114+
115+
nTimeStart = nTimeEnd;
116+
XClient_TCPSelect_SendMsg(m_Socket, (LPCXSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
117+
}
118+
}
101119
std::this_thread::sleep_for(std::chrono::milliseconds(10));
102120
}
103121
return 0;
@@ -514,7 +532,7 @@ int main()
514532
AuthClient_GetPass();
515533
AuthClient_GetTime();
516534

517-
std::this_thread::sleep_for(std::chrono::seconds(10));
535+
std::this_thread::sleep_for(std::chrono::seconds(100));
518536
AuthClient_Delete();
519537
AuthClient_Try();
520538

XEngine_Apps/Authorize_ClientModule/Authorize_ClientModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ int TestClient_TryLogin()
5555
}
5656
int main()
5757
{
58+
TestClient_HardLogin();
5859
TestClient_TryLogin();
5960
return 0;
6061
}

0 commit comments

Comments
 (0)