Skip to content

Commit fb95795

Browse files
authored
Merge pull request #6 from libxengine/develop
V2.1 Merge
2 parents e8bb580 + b7b6f4a commit fb95795

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1190
-885
lines changed

README.en.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ this software support following features
2222
7. load balanc(planning)
2323
8. message get time
2424
9. message subcribe
25-
10. support Permission Validation(planning)
25+
10. support Permission Validation
2626
11. support multi protocol(TCP,HTTP,WEBSOCKET)
2727
12. Active delivery acquisition mode or passive subscription notification module
2828
13. get order and start serial pos setting
@@ -33,7 +33,7 @@ this software support following features
3333

3434
#### Requirements
3535
support system above windows 7sp1 and linux(ubuntu20.04,centos8)
36-
XEngine need V7.18 or above
36+
XEngine need V7.23 or above
3737
vcpkg need 2021.05.11 or above
3838

3939
#### Windows
@@ -46,11 +46,6 @@ vcpkg.exe install jsoncpp
4646
vcpkg integrate install
4747
you can not use vcpkg and config jsoncpp development for youself
4848

49-
##### XEngine
50-
XEngine can be download with mine repository,whe you downloaded xengine,you have to add value to you user environment
51-
- XEngine_Include header file path
52-
- XEngine_Library library file path
53-
5449
#### Linux
5550
Linux use Makefile to complie
5651
supproted ubuntu x64 or centos x64
@@ -71,6 +66,11 @@ make complie
7166
make FLAGS=InstallAll install
7267
make FLAGS=CleanAll clear
7368

69+
#### XEngine Env
70+
install XEngine can be refer to xengine Readme docment
71+
GITEE:https://gitee.com/xyry/libxengine
72+
GITHUB:https://github.com/libxengine/xengine
73+
7474
#### use
7575

7676
1. Switch to the MASTER branch
@@ -89,6 +89,10 @@ make FLAGS=CleanAll clear
8989
## other problems
9090
You can refer to the document under the docment directory. It contains API protocol and service description.
9191

92+
## Test Server Address
93+
Address:app.xyry.org or 159.75.200.173
94+
Port:TCP 5200,HTTP 5201,WEBSOCKET 5202
95+
9296
## Participate in contribution
9397

9498
1. Fork this code

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ c c++Message Service
2121
7. 负载均衡(planning)
2222
8. 消息次数
2323
9. 消息订阅
24-
10. 支持权限验证(planning)
24+
10. 支持权限验证
2525
11. 支持多种协议(TCP,HTTP,WEBSOCKET)
2626
12. 主动投递获取模式或者被动订阅通知模块
2727
13. 获取顺序与开始序列号设置
@@ -32,7 +32,7 @@ c c++Message Service
3232

3333
#### 版本需求
3434
支持WINDOWS 7SP1和LINUX(UBUNT20.04,CENTOS8)以上系统
35-
XEngine版本需要V7.18或者以上版本
35+
XEngine版本需要V7.23或者以上版本
3636
vcpkg 需要2021.05.11以上版本
3737

3838
#### Windows
@@ -45,11 +45,6 @@ vcpkg 需要2021.05.11以上版本
4545
集成VS环境: vcpkg integrate install
4646
vcpkg 主要为了方便安装jsoncpp,如果你想自己配置jsoncpp的环境,可以不使用vcpkg...
4747

48-
##### XEngine环境
49-
XEngine可以直接下载,下载完毕后添加用户环境变量,需要下面两个
50-
- XEngine_Include 指向头文件目录地址
51-
- XEngine_Library 指向库文件目录地址
52-
5348
#### Linux
5449
Linux使用Makefile编译
5550
UBUNTU20.04 x64或者CENTOS8 x64均可
@@ -60,14 +55,17 @@ sudo apt install libjsoncpp-devel
6055
Centos8.x
6156
sudo dnf install jsoncpp-devel
6257

63-
##### XEngine环境
64-
XEngine可以通过脚本文件安装sudo XEngine_RunEnv.sh -i 3
6558
##### 编译命令
6659
在XEngine_Source目录下执行命令
6760
make 编译
6861
make FLAGS=InstallAll 安装库程序
6962
make FLAGS=CleanAll 清理编译
7063

64+
#### XEngine环境
65+
安装XEngine可以参考其Readme文档
66+
GITEE:https://gitee.com/xyry/libxengine
67+
GITHUB:https://github.com/libxengine/xengine
68+
7169
#### 使用说明
7270

7371
1. 切换到MASTER分支
@@ -86,6 +84,10 @@ make FLAGS=CleanAll 清理编译
8684
## 其他问题
8785
你可以参考docment目录下的文档.里面包含了API协议和服务说明.
8886

87+
## 测试服务器
88+
地址:app.xyry.org 或者 159.75.200.173
89+
端口:TCP 5200,HTTP 5201,WEBSOCKET 5202
90+
8991
## 参与贡献
9092

9193
1. Fork 本仓库

XEngine_Apps/MQCore_HTTPApp/MQCore_HTTPApp.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,37 @@
2727

2828
SOCKET m_Socket;
2929
LPCTSTR lpszKey = _T("XEngine_Notify"); //主题
30-
LPCTSTR lpszPostUrl = _T("http://192.168.1.7:5201");
30+
LPCTSTR lpszPostUrl = _T("http://127.0.0.1:5201");
31+
32+
void MQ_Authorize()
33+
{
34+
int nLen = 0;
35+
TCHAR tszMsgBuffer[2048];
36+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
37+
38+
Json::Value st_JsonRoot;
39+
Json::Value st_JsonAuth;
40+
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
41+
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REQLOGIN;
42+
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
43+
44+
st_JsonAuth["tszUserName"] = "123123aa";
45+
st_JsonAuth["tszUserPass"] = "123123";
46+
47+
st_JsonRoot["st_Auth"] = st_JsonAuth;
48+
49+
nLen = st_JsonRoot.toStyledString().length();
50+
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
51+
52+
TCHAR* ptszMsgBody = NULL;
53+
if (!APIHelp_HttpRequest_Post(lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
54+
{
55+
printf("发送投递失败!\n");
56+
return;
57+
}
58+
printf("MQ_Authorize:%s\n", ptszMsgBody);
59+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
60+
}
3161

3262
void MQ_Create()
3363
{
@@ -198,6 +228,7 @@ int main()
198228
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
199229
#endif
200230

231+
MQ_Authorize();
201232
MQ_Create();
202233
MQ_Post("123hello");
203234
MQ_GetNumber();

XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.cpp

Lines changed: 51 additions & 0 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,"Ws2_32.lib")
5+
#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib.lib")
56
#pragma comment(lib,"x86/XEngine_Client/XClient_Socket.lib")
67
#else
78
#include <stdio.h>
@@ -12,6 +13,8 @@
1213
using namespace std;
1314
#include <XEngine_Include/XEngine_CommHdr.h>
1415
#include <XEngine_Include/XEngine_ProtocolHdr.h>
16+
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
17+
#include <XEngine_Include/XEngine_BaseLib/Algorithm_Error.h>
1518
#include <XEngine_Include/XEngine_Client/XClient_Define.h>
1619
#include <XEngine_Include/XEngine_Client/XClient_Error.h>
1720
#include "../../XEngine_Source/XQueue_ProtocolHdr.h"
@@ -21,6 +24,53 @@ SOCKET m_Socket;
2124
__int64x nLastNumber = 0;
2225
LPCTSTR lpszKey = _T("XEngine_Notify"); //主题
2326

27+
void MQ_Authorize()
28+
{
29+
int nLen = 0;
30+
XENGINE_PROTOCOLHDR st_ProtocolHdr;
31+
XENGINE_PROTOCOL_USERAUTH st_ProtocolAuth;
32+
TCHAR tszMsgBuffer[2048];
33+
34+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
35+
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
36+
memset(&st_ProtocolAuth, '\0', sizeof(XENGINE_PROTOCOL_USERAUTH));
37+
38+
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
39+
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
40+
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REQLOGIN;
41+
st_ProtocolHdr.byVersion = 1;
42+
st_ProtocolHdr.byIsReply = TRUE; //获得处理返回结果
43+
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
44+
45+
_tcscpy(st_ProtocolAuth.tszUserName, "123123aa");
46+
_tcscpy(st_ProtocolAuth.tszUserPass, "123123");
47+
48+
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_USERAUTH);
49+
50+
nLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
51+
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
52+
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), &st_ProtocolAuth, sizeof(XENGINE_PROTOCOL_USERAUTH));
53+
54+
if (!XClient_TCPSelect_SendMsg(m_Socket, tszMsgBuffer, nLen))
55+
{
56+
printf("发送投递失败!\n");
57+
return;
58+
}
59+
nLen = 0;
60+
TCHAR* ptszMsgBuffer;
61+
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
62+
if (!XClient_TCPSelect_RecvPkt(m_Socket, &ptszMsgBuffer, &nLen, &st_ProtocolHdr))
63+
{
64+
printf("接受数据失败!\n");
65+
return;
66+
}
67+
printf("%d\n", st_ProtocolHdr.wReserve);
68+
if (nLen > 0)
69+
{
70+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
71+
}
72+
}
73+
2474
void MQ_Create()
2575
{
2676
int nLen = 0;
@@ -434,6 +484,7 @@ int main(int argc, char** argv)
434484
}
435485
printf("连接成功!\n");
436486

487+
//MQ_Authorize();
437488
if (argc > 1)
438489
{
439490
MQ_Create();

XEngine_Apps/MQCore_WSApp/MQCore_WSApp.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,42 @@ BOOL MQ_RecvPacket(TCHAR* ptszMsgBuffer, int* pInt_MsgLen)
6363
*pInt_MsgLen = nRVLen;
6464
return TRUE;
6565
}
66+
67+
void MQ_Authorize()
68+
{
69+
int nLen = 0;
70+
TCHAR tszMsgBuffer[2048];
71+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
72+
73+
Json::Value st_JsonRoot;
74+
Json::Value st_JsonAuth;
75+
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
76+
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REQLOGIN;
77+
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
78+
79+
st_JsonAuth["tszUserName"] = "123123aa";
80+
st_JsonAuth["tszUserPass"] = "123123";
81+
82+
st_JsonRoot["st_Auth"] = st_JsonAuth;
83+
84+
nLen = st_JsonRoot.toStyledString().length();
85+
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
86+
87+
if (!MQ_SendPacket(tszMsgBuffer, nLen))
88+
{
89+
printf("发送投递失败!\n");
90+
return;
91+
}
92+
nLen = 2048;
93+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
94+
if (!MQ_RecvPacket(tszMsgBuffer, &nLen))
95+
{
96+
printf("接受数据失败!\n");
97+
return;
98+
}
99+
printf("MQ_Authorize:%s\n", tszMsgBuffer);
100+
}
101+
66102
void MQ_Create()
67103
{
68104
int nLen = 0;
@@ -341,7 +377,7 @@ int main()
341377
printf("RfcComponents_WSConnector_Connect:%lX", WSFrame_GetLastError());
342378
return -1;
343379
}
344-
if (!XClient_TCPSelect_Create(&m_Socket, _T("192.168.1.7"), 5202))
380+
if (!XClient_TCPSelect_Create(&m_Socket, _T("127.0.0.1"), 5202))
345381
{
346382
printf("NetClient_TCPSelect_Create:%lX", XClient_GetLastError());
347383
return -1;
@@ -370,7 +406,7 @@ int main()
370406
{
371407
printf("%s\n", tszMsgBuffer + nPos);
372408
}
373-
409+
MQ_Authorize();
374410
MQ_Create();
375411
MQ_Post("123hello");
376412
MQ_GetSerial();

XEngine_Docment/Docment_en.docx

2.83 KB
Binary file not shown.

XEngine_Docment/Docment_zh.docx

2.68 KB
Binary file not shown.

0 commit comments

Comments
 (0)