File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ bool bRun = true;
4040bool bLogin = true ;
4141bool bTimeOut = true ;
4242bool bEncrypto = false ;
43+ bool bHeart = true ;
4344XNETHANDLE xhToken = 0 ;
4445int nDYCode = 0 ;
4546
@@ -53,6 +54,7 @@ __int64x nIDNumber = 511025111111111111;
5354
5455XHTHREAD 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
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ int TestClient_TryLogin()
5555}
5656int main ()
5757{
58+ TestClient_HardLogin ();
5859 TestClient_TryLogin ();
5960 return 0 ;
6061}
You can’t perform that action at this time.
0 commit comments