Skip to content

Commit 19b98a7

Browse files
committed
update:forward example
1 parent 22bfca1 commit 19b98a7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

XEngine_APPClient/APPClient_ForwardExample/APPClient_ForwardExample.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,31 @@ int main(int argc, char** argv)
4545

4646
int nMsgLen = 0;
4747
XENGINE_PROTOCOLHDR st_ProtocolHdr;
48+
XENGINE_PROTOCOL_USERAUTH st_UserAuth;
49+
4850
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
51+
memset(&st_UserAuth, '\0', sizeof(XENGINE_PROTOCOL_USERAUTH));
4952
//登录
5053
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
5154
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
5255
st_ProtocolHdr.byIsReply = true;
5356
st_ProtocolHdr.byVersion = 0;
57+
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_USERAUTH);
5458
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
5559
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREQ;
5660

61+
_tcsxcpy(st_UserAuth.tszUserName, "test");
62+
5763
if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCXSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR)))
5864
{
5965
printf("发送失败!\n");
6066
return 0;
6167
}
68+
if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCXSTR)&st_UserAuth, sizeof(XENGINE_PROTOCOL_USERAUTH)))
69+
{
70+
printf("发送失败!\n");
71+
return 0;
72+
}
6273

6374
nMsgLen = 0;
6475
XCHAR* ptszMsgBuffer = NULL;
@@ -104,7 +115,7 @@ int main(int argc, char** argv)
104115
//请求绑定
105116
Json::Value st_JsonRoot;
106117
Json::Value st_JsonArray = st_JsonAddr["Array"];
107-
st_JsonRoot["tszDstAddr"] = st_JsonArray[0].asCString();
118+
st_JsonRoot["tszDstAddr"] = st_JsonArray[0]["tszSrcAddr"].asCString();
108119

109120
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
110121
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
@@ -172,7 +183,7 @@ int main(int argc, char** argv)
172183
}
173184
}
174185

175-
std::this_thread::sleep_for(std::chrono::seconds(5000));
186+
std::this_thread::sleep_for(std::chrono::seconds(20000));
176187
XClient_TCPSelect_Close(m_Socket);
177188
#ifdef _MSC_BUILD
178189
WSACleanup();

XEngine_APPClient/APPClient_ForwardExample/APPClient_ForwardExample.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<ClCompile>
7979
<WarningLevel>Level3</WarningLevel>
8080
<SDLCheck>true</SDLCheck>
81-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
81+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8282
<ConformanceMode>true</ConformanceMode>
8383
</ClCompile>
8484
<Link>

0 commit comments

Comments
 (0)