Skip to content

Commit 738b5c4

Browse files
committed
example:delete language and add weather and region and api query example
1 parent fe2e068 commit 738b5c4

23 files changed

+549
-43
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#ifdef _MSC_BUILD
2+
#include <Windows.h>
3+
#include <tchar.h>
4+
#pragma comment(lib,"Ws2_32")
5+
#pragma comment(lib,"jsoncpp")
6+
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
7+
#pragma comment(lib,"XEngine_Client/XClient_APIHelp")
8+
#endif
9+
#include <stdio.h>
10+
#include <stdlib.h>
11+
#include <string.h>
12+
#include <inttypes.h>
13+
#include <json/json.h>
14+
#include <XEngine_Include/XEngine_CommHdr.h>
15+
#include <XEngine_Include/XEngine_ProtocolHdr.h>
16+
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
17+
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
18+
#include <XEngine_Include/XEngine_Client/APIClient_Define.h>
19+
#include <XEngine_Include/XEngine_Client/APIClient_Error.h>
20+
21+
//需要优先配置XEngine
22+
//WINDOWS支持VS2022 x64 debug 编译调试
23+
//g++ -std=c++17 -Wall -g APPClient_APIQueryExample.cpp -o APPClient_APIQueryExample.exe -I ../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp -L ../../XEngine_Release -lXEngine_BaseLib -lXClient_APIHelp -ljsoncpp -Wl,-rpath=../../XEngine_Release
24+
25+
int main()
26+
{
27+
#ifdef _MSC_BUILD
28+
WSADATA st_WSAData;
29+
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
30+
#endif
31+
int nLen = 0;
32+
int nCode = 0;
33+
XCHAR tszMsgBuffer[1024];
34+
LPCXSTR lpszTypeOne = _X("http://127.0.0.1:5501/api?function=ip&param=117.172.221.14");
35+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
36+
XCHAR* ptszMsgBuffer = NULL;
37+
if (!APIClient_Http_Request(_X("GET"), lpszTypeOne, NULL, &nCode, &ptszMsgBuffer, &nLen))
38+
{
39+
printf("发送投递失败!\n");
40+
return 0;
41+
}
42+
#ifdef _MSC_BUILD
43+
BaseLib_Charset_UTFToAnsi(ptszMsgBuffer, tszMsgBuffer, &nLen);
44+
printf("接受到数据,大小:%d,内容:%s\n", nLen, tszMsgBuffer);
45+
#else
46+
printf("接受到数据,大小:%d,内容:%s\n", nLen, ptszMsgBuffer);
47+
#endif
48+
BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
49+
//////////////////////////////////////////////////////////////////////////
50+
nLen = 0;
51+
nCode = 0;
52+
LPCXSTR lpszTypeZ = _X("http://127.0.0.1:5501/api?function=mac&param=00:00:0C");
53+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
54+
if (!APIClient_Http_Request(_X("GET"), lpszTypeZ, NULL, &nCode, &ptszMsgBuffer, &nLen))
55+
{
56+
printf("发送投递失败!\n");
57+
return 0;
58+
}
59+
#ifdef _MSC_BUILD
60+
BaseLib_Charset_UTFToAnsi(ptszMsgBuffer, tszMsgBuffer, &nLen);
61+
printf("接受到数据,大小:%d,内容:%s\n", nLen, tszMsgBuffer);
62+
#else
63+
printf("接受到数据,大小:%d,内容:%s\n", nLen, ptszMsgBuffer);
64+
#endif
65+
BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
66+
#ifdef _MSC_BUILD
67+
WSACleanup();
68+
#endif
69+
return 0;
70+
}

XEngine_APPClient/APPClient_LanguageExample/APPClient_LanguageExample.vcxproj renamed to XEngine_APPClient/APPClient_APIQueryExample/APPClient_APIQueryExample.vcxproj

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
</ProjectConfiguration>
2020
</ItemGroup>
2121
<PropertyGroup Label="Globals">
22-
<VCProjectVersion>16.0</VCProjectVersion>
22+
<VCProjectVersion>17.0</VCProjectVersion>
2323
<Keyword>Win32Proj</Keyword>
24-
<ProjectGuid>{1b028466-937d-4d6c-a7ed-a0bd5c312878}</ProjectGuid>
25-
<RootNamespace>APPClientLanguageExample</RootNamespace>
24+
<ProjectGuid>{58ebbc6b-e384-4f7a-ae1c-99f5fbfd63ac}</ProjectGuid>
25+
<RootNamespace>APPClientAPIQueryExample</RootNamespace>
2626
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
2727
</PropertyGroup>
2828
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -43,7 +43,7 @@
4343
<ConfigurationType>Application</ConfigurationType>
4444
<UseDebugLibraries>true</UseDebugLibraries>
4545
<PlatformToolset>v143</PlatformToolset>
46-
<CharacterSet>MultiByte</CharacterSet>
46+
<CharacterSet>Unicode</CharacterSet>
4747
</PropertyGroup>
4848
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
4949
<ConfigurationType>Application</ConfigurationType>
@@ -71,20 +71,12 @@
7171
</ImportGroup>
7272
<PropertyGroup Label="UserMacros" />
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74-
<LinkIncremental>true</LinkIncremental>
7574
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath)</IncludePath>
7675
<LibraryPath>$(XEngine_Lib32);../../XEngine_Source/Debug;$(LibraryPath)</LibraryPath>
7776
</PropertyGroup>
78-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79-
<LinkIncremental>false</LinkIncremental>
80-
</PropertyGroup>
8177
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
82-
<LinkIncremental>true</LinkIncremental>
83-
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
84-
<LibraryPath>$(XEngine_Lib64);$(LibraryPath)</LibraryPath>
85-
</PropertyGroup>
86-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
87-
<LinkIncremental>false</LinkIncremental>
78+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath)</IncludePath>
79+
<LibraryPath>$(XEngine_Lib64);../../XEngine_Source/x64/Debug;$(LibraryPath)</LibraryPath>
8880
</PropertyGroup>
8981
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
9082
<ClCompile>
@@ -143,7 +135,7 @@
143135
</Link>
144136
</ItemDefinitionGroup>
145137
<ItemGroup>
146-
<ClCompile Include="APPClient_LanguageExample.cpp" />
138+
<ClCompile Include="APPClient_APIQueryExample.cpp" />
147139
</ItemGroup>
148140
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
149141
<ImportGroup Label="ExtensionTargets">

XEngine_APPClient/APPClient_LanguageExample/APPClient_LanguageExample.vcxproj.filters renamed to XEngine_APPClient/APPClient_APIQueryExample/APPClient_APIQueryExample.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</Filter>
1616
</ItemGroup>
1717
<ItemGroup>
18-
<ClCompile Include="APPClient_LanguageExample.cpp">
18+
<ClCompile Include="APPClient_APIQueryExample.cpp">
1919
<Filter>源文件</Filter>
2020
</ClCompile>
2121
</ItemGroup>

XEngine_APPClient/APPClient_LanguageExample/APPClient_LanguageExample.vcxproj.user renamed to XEngine_APPClient/APPClient_APIQueryExample/APPClient_APIQueryExample.vcxproj.user

File renamed without changes.

XEngine_APPClient/APPClient_BackExample/APPClient_BackExample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int test_query()
3232
XCHAR* ptszMsgBuffer = NULL;
3333

3434
Json::Value st_JsonRoot;
35-
st_JsonRoot["tszSrcBuffer"] = "D:\\XEngine_APIService\\XEngine_Release\\*";
35+
st_JsonRoot["tszSrcBuffer"] = "D:\\XEngine_APIService\\XEngine_Release\\";
3636

3737
if (!APIClient_Http_Request(_X("POST"), lpszAPIUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
3838
{

XEngine_APPClient/APPClient_DeamonExample/APPClient_DeamonExample.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ int test_insert()
3333

3434
Json::Value st_JsonRoot;
3535
st_JsonRoot["bEnable"] = true;
36-
st_JsonRoot["nRetime"] = 3;
36+
st_JsonRoot["nRetime"] = 0;
37+
st_JsonRoot["nReNumber"] = 3;
3738
st_JsonRoot["tszAPPName"] = "Fairdell_HexCmp2.exe";
3839
st_JsonRoot["tszAPPPath"] = "D:\\";
3940

XEngine_APPClient/APPClient_IDExample/APPClient_IDExample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int main()
2929
#endif
3030
int nLen = 0;
3131
XCHAR* ptszMsgBuffer = NULL;
32-
LPCXSTR lpszUrl = _X("http://127.0.0.1:5501/api?function=id&params1=511025198807018792&params2=0");
32+
LPCXSTR lpszUrl = _X("http://127.0.0.1:5501/api?function=id&params1=511000191107018112&params2=0");
3333

3434
if (!APIClient_Http_Request(_X("GET"), lpszUrl, NULL, NULL, &ptszMsgBuffer, &nLen))
3535
{

XEngine_APPClient/APPClient_ImageExample/APPClient_ImageExample.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
bool APPClient_ImageExample_GetAttr(LPCXSTR lpszMsgBuffer, int nMsgLen, int* pInt_Width, int* pInt_Height)
3535
{
3636
int nCode = 0;
37-
LPCXSTR lpszAPIUrl = _X("http://127.0.0.1:5501/api?function=image&params1=0");
37+
LPCXSTR lpszAPIUrl = _X("http://127.0.0.1:5501/api?function=image&params1=1");
3838

3939
XCHAR* ptszMsgBuffer = NULL;
4040
if (!APIClient_Http_Request(_X("POST"), lpszAPIUrl, lpszMsgBuffer, &nCode, &ptszMsgBuffer, &nMsgLen))
@@ -61,12 +61,12 @@ bool APPClient_ImageExample_GetAttr(LPCXSTR lpszMsgBuffer, int nMsgLen, int* pIn
6161
}
6262
int test_imgzoom()
6363
{
64-
LPCXSTR lpszFileDir = _X("D:\\Image\\*");
64+
LPCXSTR lpszFileDir = _X("D:\\Image\\");
6565

6666
int nListCount = 0;
6767
XCHAR** pptszListFile;
6868

69-
SystemApi_File_EnumFile(lpszFileDir, &pptszListFile, &nListCount);
69+
SystemApi_File_EnumFile(lpszFileDir, &pptszListFile, &nListCount, false, 1);
7070
for (int i = 0; i < nListCount; i++)
7171
{
7272
int nCode = 0;
@@ -80,7 +80,11 @@ int test_imgzoom()
8080
memset(ptszFileBuffer, '\0', XENGINE_MEMORY_SIZE_MAX);
8181

8282
FILE* pSt_File = _xfopen(pptszListFile[i], _X("rb"));
83-
int nRet = (int)fread(ptszFileBuffer, 1, XENGINE_MEMORY_SIZE_MAX, pSt_File);
83+
if (NULL == pSt_File)
84+
{
85+
continue;
86+
}
87+
int nRet = fread(ptszFileBuffer, 1, XENGINE_MEMORY_SIZE_MAX, pSt_File);
8488
fclose(pSt_File);
8589

8690
APPClient_ImageExample_GetAttr(ptszFileBuffer, nRet, &nWidth, &nHeight);
@@ -89,7 +93,7 @@ int test_imgzoom()
8993
XCHAR tszFileExt[64] = {};
9094

9195
BaseLib_String_GetFileAndPath(pptszListFile[i], NULL, NULL, NULL, tszFileExt);
92-
_xstprintf(tszAPIUrl, _X("http://127.0.0.1:5501/api?function=image&type=1&ext=%s&width=%d&height=%d"), tszFileExt, nWidth / 2, nHeight / 2);
96+
_xstprintf(tszAPIUrl, _X("http://127.0.0.1:5501/api?function=image&type=2&ext=%s&width=%d&height=%d"), tszFileExt, nWidth / 2, nHeight / 2);
9397

9498
XCHAR* ptszMsgBuffer = NULL;
9599
if (!APIClient_Http_Request(_X("POST"), tszAPIUrl, ptszFileBuffer, &nCode, &ptszMsgBuffer, &nRet))

XEngine_APPClient/APPClient_LuaPluginExample/APPClient_LuaPluginExample.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ int main()
3737
printf("接受到数据,大小:%d,内容:%s\n", nLen, ptszMsgBuffer);
3838
BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
3939

40-
getchar();
4140
#ifdef _MSC_BUILD
4241
WSACleanup();
4342
#endif

XEngine_APPClient/APPClient_P2PExample/APPClient_P2PExample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#pragma comment(lib,"XEngine_Client/XClient_APIHelp")
66
#pragma comment(lib,"XEngine_NetHelp/NetHelp_XSocket")
77
#pragma comment(lib,"Ws2_32")
8-
#ifdef WIN64
8+
#ifdef _WIN64
99
#pragma comment(lib,"../../XEngine_Source/x64/Debug/jsoncpp")
1010
#else
1111
#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")

0 commit comments

Comments
 (0)