Skip to content

Commit 7c67988

Browse files
committed
update:example
1 parent 03d8209 commit 7c67988

File tree

6 files changed

+52
-26
lines changed

6 files changed

+52
-26
lines changed

XEngine_APPClient/APPClient_RestApi/APPClient_RestApi.cpp

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <windows.h>
33
#include <tchar.h>
44
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
5+
#pragma comment(lib,"XEngine_Core/XEngine_OPenSsl")
56
#pragma comment(lib,"XEngine_NetHelp/NetHelp_APIClient")
67
#pragma comment(lib,"Ws2_32")
78
#ifdef _WIN64
@@ -20,29 +21,34 @@
2021
#include <XEngine_Include/XEngine_ProtocolHdr.h>
2122
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
2223
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
24+
#include <XEngine_Include/XEngine_Core/OPenSsl_Define.h>
25+
#include <XEngine_Include/XEngine_Core/OPenSsl_Error.h>
2326
#include <XEngine_Include/XEngine_NetHelp/APIClient_Define.h>
2427
#include <XEngine_Include/XEngine_NetHelp/APIClient_Error.h>
2528
using namespace std;
2629

27-
//g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp -Wl,-rpath=../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp,--disable-new-dtags
30+
//g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp -Wl,-rpath=../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp,--disable-new-dtags
2831
//需要优先配置XEngine
2932
//WINDOWS使用VS2022 x86 或者 x64 debug 编译
3033
//linux使用下面的命令编译
31-
//g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp
34+
//g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp
3235

36+
XCHAR tszBaseBuffer[MAX_PATH];
37+
XCHAR tszHdrBuffer[MAX_PATH];
3338
//查询
3439
void API_Manage_Query()
3540
{
36-
LPCXSTR lpszUrl = _X("http://192.168.1.8:5100/Api/Manage/QueryFile");
41+
LPCXSTR lpszUrl = _X("http://127.0.0.1:5100/Api/Manage/QueryFile");
3742
int nLen = 0;
3843
int nCode = 0;
3944
XCHAR* ptszMsgBuffer = NULL;
4045
Json::Value st_JsonRoot;
46+
4147
st_JsonRoot["lpszTimeStart"];
4248
st_JsonRoot["lpszTimeEnd"];
4349
st_JsonRoot["lpszBuckKey"] = "storagekey2";
4450

45-
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
51+
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
4652
{
4753
_xtprintf("API_Manage_Query:%lX\n", APIClient_GetLastError());
4854
return;
@@ -53,7 +59,7 @@ void API_Manage_Query()
5359
//插入
5460
void API_Manage_Insert()
5561
{
56-
LPCXSTR lpszUrl = _X("http://192.168.1.8:5100/Api/Manage/Insert");
62+
LPCXSTR lpszUrl = _X("http://127.0.0.1:5100/Api/Manage/Insert");
5763
int nLen = 0;
5864
int nCode = 0;
5965
XCHAR* ptszMsgBuffer = NULL;
@@ -70,7 +76,7 @@ void API_Manage_Insert()
7076
st_JsonRoot["List"] = st_JsonArray;
7177
st_JsonRoot["Count"] = 1;
7278

73-
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
79+
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
7480
{
7581
_xtprintf("API_Manage_Insert:%lX\n", APIClient_GetLastError());
7682
return;
@@ -81,7 +87,7 @@ void API_Manage_Insert()
8187
//删除
8288
void API_Manage_Delete()
8389
{
84-
LPCXSTR lpszUrl = _X("http://192.168.1.8:5100/Api/Manage/Delete");
90+
LPCXSTR lpszUrl = _X("http://127.0.0.1:5100/Api/Manage/Delete");
8591
int nLen = 0;
8692
int nCode = 0;
8793
XCHAR* ptszMsgBuffer = NULL;
@@ -95,7 +101,7 @@ void API_Manage_Delete()
95101
st_JsonRoot["List"] = st_JsonArray;
96102
st_JsonRoot["Count"] = 1;
97103

98-
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
104+
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
99105
{
100106
_xtprintf("API_Manage_Delete:%lX\n", APIClient_GetLastError());
101107
return;
@@ -106,7 +112,7 @@ void API_Manage_Delete()
106112
//文件夹
107113
void API_Manage_Dir()
108114
{
109-
LPCXSTR lpszUrl = _X("http://192.168.1.8:5100/Api/Manage/Dir");
115+
LPCXSTR lpszUrl = _X("http://127.0.0.1:5100/Api/Manage/Dir");
110116
int nLen = 0;
111117
int nCode = 0;
112118
XCHAR* ptszMsgBuffer = NULL;
@@ -115,7 +121,7 @@ void API_Manage_Dir()
115121
st_JsonRoot["lpszBuckKey"] = "storagekey1";
116122
st_JsonRoot["lpszUserDir"] = "user";
117123
st_JsonRoot["nOPerator"] = 1;
118-
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
124+
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
119125
{
120126
_xtprintf("API_Manage_Dir:%lX\n", APIClient_GetLastError());
121127
return;
@@ -127,7 +133,7 @@ void API_Manage_Dir()
127133
st_JsonRoot["lpszBuckKey"] = "storagekey1";
128134
st_JsonRoot["lpszUserDir"];
129135
st_JsonRoot["nOPerator"] = 0;
130-
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
136+
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
131137
{
132138
_xtprintf("API_Manage_Dir:%lX\n", APIClient_GetLastError());
133139
return;
@@ -139,7 +145,7 @@ void API_Manage_Dir()
139145
st_JsonRoot["lpszBuckKey"] = "storagekey1";
140146
st_JsonRoot["lpszUserDir"] = "user";
141147
st_JsonRoot["nOPerator"] = 2;
142-
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
148+
if (!APIClient_Http_Request(_X("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
143149
{
144150
_xtprintf("API_Manage_Dir:%lX\n", APIClient_GetLastError());
145151
return;
@@ -150,11 +156,11 @@ void API_Manage_Dir()
150156
//任务管理
151157
void API_Manage_Task()
152158
{
153-
LPCXSTR lpszUrl = _X("http://192.168.1.8:5100/Api/Manage/Task");
159+
LPCXSTR lpszUrl = _X("http://127.0.0.1:5100/Api/Manage/Task");
154160
int nLen = 0;
155161
int nCode = 0;
156162
XCHAR* ptszMsgBuffer = NULL;
157-
if (!APIClient_Http_Request(_X("POST"), lpszUrl, NULL, &nCode, &ptszMsgBuffer, &nLen))
163+
if (!APIClient_Http_Request(_X("POST"), lpszUrl, NULL, &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
158164
{
159165
_xtprintf("API_Manage_Task:%lX\n", APIClient_GetLastError());
160166
return;
@@ -169,6 +175,10 @@ int main()
169175
WSADATA st_WSAData;
170176
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
171177
#endif
178+
memset(tszBaseBuffer, '\0', MAX_PATH);
179+
memset(tszHdrBuffer, '\0', MAX_PATH);
180+
OPenSsl_Help_BasicEncoder("123123aa", "123123", tszBaseBuffer);
181+
_xstprintf(tszHdrBuffer, _X("Authorization: %s\r\n"), tszBaseBuffer);
172182

173183
API_Manage_Query();
174184
API_Manage_Insert();

XEngine_APPClient/APPClient_RestApi/APPClient_RestApi.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<ClCompile>
9191
<WarningLevel>Level3</WarningLevel>
9292
<SDLCheck>true</SDLCheck>
93-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
93+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9494
<ConformanceMode>true</ConformanceMode>
9595
</ClCompile>
9696
<Link>

XEngine_APPClient/APPClient_UPDate/APPClient_UPFile/APPClient_UPFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ int main(int argc, char** argv)
88
WSADATA st_WSAData;
99
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
1010
#endif
11-
LPCXSTR lpszLocalFile = _X("D:\\XEngine_Storage\\XEngine_APPClient\\Debug\\LocalFile.txt");
12-
LPCXSTR lpszDownload = _X("http://192.168.1.8:5101/storagekey1/xengine/upfile.txt");
11+
LPCXSTR lpszLocalFile = _X("D:\\XEngine_Storage\\XEngine_APPClient\\Debug\\LocalFile.json");
12+
LPCXSTR lpszDownload = _X("http://127.0.0.1:5101/storagekey1/xengine/upfile.json");
1313
XCHAR* ptszMsgBuffer = NULL;
1414
int nMsgLen = 0;
1515

XEngine_APPClient/APPClient_UPDate/APPClient_UPMaker/APPClient_UPMaker.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ bool HelpModule_Api_BuildVer(XCHAR* ptszLocalBuffer, XCHAR* ptszRemoteBuffer, in
147147
_tcsxcpy(tszDelPath, lpszPath);
148148
_tcsxcpy(tszSubPath, stl_ListIterator->tszFilePath);
149149

150-
tszDelPath[_tcsxlen(tszDelPath) - 2] = '\0';
151-
BaseLib_OperatorString_DelSub(tszDelPath, "\\");
152-
_tcsxcat(tszDelPath, "\\");
150+
tszDelPath[_tcsxlen(tszDelPath) - 1] = '\0';
153151

154152
BaseLib_OperatorString_DelSub(tszSubPath, tszDelPath);
155153
BaseLib_OperatorString_FixPath(tszSubPath, 2);
@@ -188,10 +186,15 @@ int main(int argc, char** argv)
188186
WSADATA st_WSAData;
189187
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
190188
#endif
191-
LPCXSTR lpszPath = _X("D:\\libxengine\\*");
192-
LPCXSTR lpszLocalFile = _X("D:\\XEngine_Storage\\XEngine_APPClient\\Debug\\LocalFile.txt");
193-
LPCXSTR lpszPostFile = _X("http://192.168.1.8:5102/api?filename=xengine/upfile.txt&storeagekey=storagekey1");
194-
LPCXSTR lpszDownload = _X("http://192.168.1.8:5101/storagekey1/xengine/");
189+
//要更新的目录
190+
LPCXSTR lpszPath = _X("D:\\libxengine\\*");
191+
//更新列表
192+
LPCXSTR lpszLocalFile = _X("D:\\XEngine_Storage\\XEngine_APPClient\\Debug\\LocalFile.json");
193+
//更新文件下载地址
194+
LPCXSTR lpszDownload = _X("http://127.0.0.1:5101/storagekey1/xengine/");
195+
//自动提交到我们的服务器
196+
LPCXSTR lpszPostFile = _X("http://127.0.0.1:5102/api?filename=xengine/xengine.json&storeagekey=storagekey1");
197+
195198
int nLocalLen = 1024 * 1024 * 10;
196199
int nRemoteLen = 1024 * 1024 * 10;
197200
XCHAR* ptszLocalBuffer = (XCHAR*)malloc(nLocalLen);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# APPClient_UPDate
2+
此例子演示了如何使用软件更新程序
3+
This example demonstrates how to use the software updater
4+
5+
6+
## APPClient_UPMaker
7+
更新列表生成器,你应该先生成更新列表,修改main函数里面的变量值,然后运行程序即可
8+
update list create program.you have to build update list first,Modify the variable value in the main function,and then running the program
9+
10+
11+
## APPClient_UPFile
12+
更新工具,此软件可以更新的列表进行分析需要更新的文件
13+
update program,the software can be update file throught update list

XEngine_APPClient/APPClient_UPDownload/APPClient_UPDownload.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void File_UPLoad()
5151
memset(tszKeyBuffer, '\0', MAX_PATH);
5252
OPenSsl_Help_BasicEncoder("123123aa", "123123", tszBaseBuffer);
5353

54-
_xtprintf(tszHdrBuffer, _X("Range: bytes=0-5/10\r\nAuthorization: %s\r\n"), tszBaseBuffer);
54+
_xstprintf(tszHdrBuffer, _X("Range: bytes=0-5/10\r\nAuthorization: %s\r\n"), tszBaseBuffer);
5555
if (!APIClient_Http_Request(_X("POST"), lpszUrl, lpszMsgBuffer, &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
5656
{
5757
_xtprintf("upload failed:%lX\n", APIClient_GetLastError());
@@ -84,7 +84,7 @@ void File_UPLoad()
8484
//下载文件
8585
void File_Download()
8686
{
87-
LPCXSTR lpszUrl = _X("http://192.168.1.8:5101/storagekey2/newfile4.txt");
87+
LPCXSTR lpszUrl = _X("http://127.0.0.1:5101/storagekey2/newfile4.txt");
8888

8989
int nLen = 0;
9090
XCHAR* ptszMsgBuffer = NULL;

0 commit comments

Comments
 (0)