Skip to content

Commit 592e353

Browse files
committed
added:word filter app example
1 parent d75470d commit 592e353

File tree

5 files changed

+287
-0
lines changed

5 files changed

+287
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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_NetHelp/NetHelp_APIClient")
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_NetHelp/APIClient_Define.h>
19+
#include <XEngine_Include/XEngine_NetHelp/APIClient_Error.h>
20+
21+
//需要优先配置XEngine
22+
//WINDOWS支持VS2022 x64 debug 编译调试
23+
//linux::g++ -std=c++17 -Wall -g APPClient_WordFilter.cpp -o APPClient_WordFilter.exe -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -lXEngine_BaseLib -lNetHelp_APIClient
24+
//macos::g++ -std=c++17 -Wall -g APPClient_WordFilter.cpp -o APPClient_WordFilter.exe -lXEngine_BaseLib -lNetHelp_APIClient
25+
26+
LPCXSTR lpszTableName = _T("xengine");
27+
28+
int test_insert()
29+
{
30+
int nLen = 0;
31+
int nCode = 0;
32+
LPCXSTR lpszAPIUrl = _T("http://127.0.0.1:5501/api?function=wordfilter&params1=0");
33+
34+
Json::Value st_JsonRoot;
35+
Json::StreamWriterBuilder st_JsonBuilder;
36+
st_JsonRoot["tszWordsFrom"] = "root";
37+
st_JsonRoot["tszWordsTo"] = "user";
38+
st_JsonRoot["nLevel"] = 1;
39+
40+
st_JsonBuilder["emitUTF8"] = true;
41+
42+
XCHAR* ptszMsgBuffer = NULL;
43+
if (!APIClient_Http_Request(_T("POST"), lpszAPIUrl, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), &nCode, &ptszMsgBuffer, &nLen))
44+
{
45+
printf("发送投递失败!\n");
46+
return 0;
47+
}
48+
printf("接受到数据,大小:%d,内容:%s\n", nLen, ptszMsgBuffer);
49+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
50+
51+
return 0;
52+
}
53+
int test_query()
54+
{
55+
int nLen = 0;
56+
int nCode = 0;
57+
LPCXSTR lpszAPIUrl = _T("http://127.0.0.1:5501/api?function=wordfilter&params1=2");
58+
59+
Json::Value st_JsonRoot;
60+
st_JsonRoot["tszWordsFrom"] = "root";
61+
62+
XCHAR* ptszMsgBuffer = NULL;
63+
if (!APIClient_Http_Request(_T("POST"), lpszAPIUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
64+
{
65+
printf("发送投递失败!\n");
66+
return 0;
67+
}
68+
printf("接受到数据,大小:%d,内容:%s\n", nLen, ptszMsgBuffer);
69+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
70+
71+
return 0;
72+
}
73+
int test_delete()
74+
{
75+
int nLen = 0;
76+
int nCode = 0;
77+
LPCXSTR lpszAPIUrl = _T("http://127.0.0.1:5501/api?function=wordfilter&params1=1");
78+
79+
Json::Value st_JsonRoot;
80+
st_JsonRoot["tszWordsFrom"] = "root";
81+
82+
XCHAR* ptszMsgBuffer = NULL;
83+
if (!APIClient_Http_Request(_T("POST"), lpszAPIUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
84+
{
85+
printf("发送投递失败!\n");
86+
return 0;
87+
}
88+
printf("接受到数据,大小:%d,内容:%s\n", nLen, ptszMsgBuffer);
89+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
90+
91+
return 0;
92+
}
93+
94+
int main()
95+
{
96+
#ifdef _MSC_BUILD
97+
WSADATA st_WSAData;
98+
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
99+
#endif
100+
test_insert();
101+
test_query();
102+
test_delete();
103+
104+
#ifdef _MSC_BUILD
105+
WSACleanup();
106+
#endif
107+
return 0;
108+
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{6f2d2186-1ed7-444d-9981-1acae4226811}</ProjectGuid>
25+
<RootNamespace>APPClientWordFilter</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>MultiByte</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>MultiByte</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
74+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
75+
<LibraryPath>$(XEngine_Lib64);../../XEngine_Source/x64/Debug;$(LibraryPath)</LibraryPath>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
78+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
79+
<LibraryPath>$(XEngine_Lib32);$(LibraryPath)</LibraryPath>
80+
</PropertyGroup>
81+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
82+
<ClCompile>
83+
<WarningLevel>Level3</WarningLevel>
84+
<SDLCheck>true</SDLCheck>
85+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
86+
<ConformanceMode>true</ConformanceMode>
87+
</ClCompile>
88+
<Link>
89+
<SubSystem>Console</SubSystem>
90+
<GenerateDebugInformation>true</GenerateDebugInformation>
91+
</Link>
92+
</ItemDefinitionGroup>
93+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
94+
<ClCompile>
95+
<WarningLevel>Level3</WarningLevel>
96+
<FunctionLevelLinking>true</FunctionLevelLinking>
97+
<IntrinsicFunctions>true</IntrinsicFunctions>
98+
<SDLCheck>true</SDLCheck>
99+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
100+
<ConformanceMode>true</ConformanceMode>
101+
</ClCompile>
102+
<Link>
103+
<SubSystem>Console</SubSystem>
104+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
105+
<OptimizeReferences>true</OptimizeReferences>
106+
<GenerateDebugInformation>true</GenerateDebugInformation>
107+
</Link>
108+
</ItemDefinitionGroup>
109+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
110+
<ClCompile>
111+
<WarningLevel>Level3</WarningLevel>
112+
<SDLCheck>true</SDLCheck>
113+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
114+
<ConformanceMode>true</ConformanceMode>
115+
</ClCompile>
116+
<Link>
117+
<SubSystem>Console</SubSystem>
118+
<GenerateDebugInformation>true</GenerateDebugInformation>
119+
</Link>
120+
</ItemDefinitionGroup>
121+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
122+
<ClCompile>
123+
<WarningLevel>Level3</WarningLevel>
124+
<FunctionLevelLinking>true</FunctionLevelLinking>
125+
<IntrinsicFunctions>true</IntrinsicFunctions>
126+
<SDLCheck>true</SDLCheck>
127+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
128+
<ConformanceMode>true</ConformanceMode>
129+
</ClCompile>
130+
<Link>
131+
<SubSystem>Console</SubSystem>
132+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
133+
<OptimizeReferences>true</OptimizeReferences>
134+
<GenerateDebugInformation>true</GenerateDebugInformation>
135+
</Link>
136+
</ItemDefinitionGroup>
137+
<ItemGroup>
138+
<ClCompile Include="APPClient_WordFilter.cpp" />
139+
</ItemGroup>
140+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
141+
<ImportGroup Label="ExtensionTargets">
142+
</ImportGroup>
143+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="源文件">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="头文件">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="资源文件">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="APPClient_WordFilter.cpp">
19+
<Filter>源文件</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

XEngine_APPClient/XEngine_APPClient.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APPClient_DTestExample", "A
3535
EndProject
3636
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APPClient_SocketExample", "APPClient_SocketExample\APPClient_SocketExample.vcxproj", "{5DF5E1D4-318C-468D-A427-88D873E095D3}"
3737
EndProject
38+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APPClient_WordFilter", "APPClient_WordFilter\APPClient_WordFilter.vcxproj", "{6F2D2186-1ED7-444D-9981-1ACAE4226811}"
39+
EndProject
3840
Global
3941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4042
Debug|x64 = Debug|x64
@@ -171,6 +173,14 @@ Global
171173
{5DF5E1D4-318C-468D-A427-88D873E095D3}.Release|x64.Build.0 = Release|x64
172174
{5DF5E1D4-318C-468D-A427-88D873E095D3}.Release|x86.ActiveCfg = Release|Win32
173175
{5DF5E1D4-318C-468D-A427-88D873E095D3}.Release|x86.Build.0 = Release|Win32
176+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Debug|x64.ActiveCfg = Debug|x64
177+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Debug|x64.Build.0 = Debug|x64
178+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Debug|x86.ActiveCfg = Debug|Win32
179+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Debug|x86.Build.0 = Debug|Win32
180+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Release|x64.ActiveCfg = Release|x64
181+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Release|x64.Build.0 = Release|x64
182+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Release|x86.ActiveCfg = Release|Win32
183+
{6F2D2186-1ED7-444D-9981-1ACAE4226811}.Release|x86.Build.0 = Release|Win32
174184
EndGlobalSection
175185
GlobalSection(SolutionProperties) = preSolution
176186
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)