Skip to content

Commit 17f7414

Browse files
authored
Merge pull request #10 from libxengine/develop
V3.3.0.1001 Merge
2 parents 5d0d75d + 8fca4a8 commit 17f7414

Some content is hidden

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

58 files changed

+635
-1374
lines changed

CHANGELOG

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
XEngine_MQService V3.3.0.1001
2+
3+
添加:定时发布功能
4+
添加:为会话模块添加获取用户网络类型的功能
5+
修复:某些时候程序退出崩溃
6+
修复:重复订阅现在不允许了
7+
修复:用户离开订阅还存在的问题
8+
修复:订阅的消息会发送给自己的问题
9+
修复:登录打印不正确的问题
10+
删除:DDS模块和相关代码
11+
12+
added:Timed Release
13+
added:get user net type for session module
14+
fixed:sometime is crashed when program exit
15+
fixed:Duplicate subscriptions are not allowed
16+
fixed:The problem that the user leaves the subscription is work
17+
fixed:the problem that subscribe messages sent to yourself
18+
fixed:login printf is incorrent
19+
delete:dds module and Delete related functions
20+
======================================================================================
121
XEngine_MQService V3.2.0.1001
222

323
添加:为会话模块添加心跳

README.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ this software support following features
2828
12. Active delivery acquisition mode or passive subscription notification module
2929
13. get order and start serial pos setting
3030
14. Unlimited load message types
31-
15. data distribution service(DDS),Support WAN and LAN
31+
15. timed message
3232
16. Access control(planning)
3333

3434
## install

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ c c++Message Service
2727
12. 主动投递获取模式或者被动订阅通知模块
2828
13. 获取顺序与开始序列号设置
2929
14. 不限制负载的消息类型
30-
15. 消息分发服务(DDS),支持广域网和局域网
30+
15. 定时消息
3131
16. 权限控制(planning)
3232

3333
## 安装教程
@@ -95,7 +95,6 @@ make FLAGS=CleanAll 清理编译
9595
如果你觉得这个软件对你有帮助,请你给我们一个START吧
9696

9797
## 开发计划
98-
DDS消息订阅与发布
9998
扩展获取消息的内容
10099
消息属性生效
101100
删除包协议

XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.cpp

Lines changed: 71 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,58 @@ void MQ_Get()
320320
std::this_thread::sleep_for(std::chrono::milliseconds(1));
321321
}
322322
}
323+
324+
void MQ_TimePublish()
325+
{
326+
int nLen = 0;
327+
LPCTSTR lpszMsgBuffer = _T("hello world");
328+
XENGINE_PROTOCOLHDR st_ProtocolHdr;
329+
XENGINE_PROTOCOL_XMQ st_XMQProtocol;
330+
TCHAR tszMsgBuffer[2048];
331+
332+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
333+
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
334+
memset(&st_XMQProtocol, '\0', sizeof(XENGINE_PROTOCOL_XMQ));
335+
336+
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
337+
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
338+
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQPOST;
339+
st_ProtocolHdr.byVersion = 1;
340+
st_ProtocolHdr.byIsReply = TRUE; //必须为真
341+
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
342+
343+
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_XMQ) + _tcslen(lpszMsgBuffer);
344+
st_XMQProtocol.nSerial = 0; //要获取的序列号,如果为0,服务会自动处理
345+
st_XMQProtocol.nPubTime = time(NULL) + 60; //当前时间+60秒
346+
strcpy(st_XMQProtocol.tszMQKey, lpszKey);
347+
348+
nLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
349+
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
350+
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), &st_XMQProtocol, sizeof(XENGINE_PROTOCOL_XMQ));
351+
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_XMQ), lpszMsgBuffer, _tcslen(lpszMsgBuffer));
352+
353+
if (!XClient_TCPSelect_SendMsg(m_Socket, tszMsgBuffer, nLen))
354+
{
355+
printf("发送投递失败!\n");
356+
return;
357+
}
358+
nLen = 0;
359+
CHAR* ptszMsgBuffer = NULL;
360+
if (!XClient_TCPSelect_RecvPkt(m_Socket, &ptszMsgBuffer, &nLen, &st_ProtocolHdr))
361+
{
362+
printf("接受数据失败!\n");
363+
return;
364+
}
365+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
366+
367+
if (!XClient_TCPSelect_RecvPkt(m_Socket, &ptszMsgBuffer, &nLen, &st_ProtocolHdr, 60))
368+
{
369+
printf("接受数据失败!\n");
370+
return;
371+
}
372+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
373+
}
374+
323375
void MQ_GetNumber()
324376
{
325377
int nLen = 0;
@@ -393,7 +445,7 @@ void MQ_GetSerial()
393445

394446
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_XMQ);
395447

396-
st_XMQProtocol.nSerial = 10; //设置为10开始读取
448+
st_XMQProtocol.nSerial = 5; //设置为5开始读取
397449
strcpy(st_XMQProtocol.tszMQKey, lpszKey);
398450

399451
nLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
@@ -492,29 +544,14 @@ void MQ_Subscribe()
492544
printf("发送投递失败!\n");
493545
return;
494546
}
495-
while (TRUE)
547+
nLen = 0;
548+
CHAR* ptszMsgBuffer = NULL;
549+
if (!XClient_TCPSelect_RecvPkt(m_Socket, &ptszMsgBuffer, &nLen, &st_ProtocolHdr))
496550
{
497-
nLen = 2048;
498-
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
499-
if (XClient_TCPSelect_RecvMsg(m_Socket, tszMsgBuffer, &nLen))
500-
{
501-
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
502-
memset(&st_XMQProtocol, '\0', sizeof(XENGINE_PROTOCOL_XMQ));
503-
504-
memcpy(&st_ProtocolHdr, tszMsgBuffer, sizeof(XENGINE_PROTOCOLHDR));
505-
memcpy(&st_XMQProtocol, tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), sizeof(XENGINE_PROTOCOL_XMQ));
506-
507-
if (0 == st_ProtocolHdr.wReserve)
508-
{
509-
printf("接受到数据,主题:%s,序列:%lld,长度:%d,内容:%s\n", st_XMQProtocol.tszMQKey, st_XMQProtocol.nSerial, st_ProtocolHdr.unPacketSize - sizeof(XENGINE_PROTOCOL_XMQ), tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_XMQ));
510-
}
511-
else
512-
{
513-
printf("获取消息队列数据失败,错误码:%d\n", st_ProtocolHdr.wReserve);
514-
}
515-
}
516-
std::this_thread::sleep_for(std::chrono::milliseconds(1));
551+
printf("接受数据失败!\n");
552+
return;
517553
}
554+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
518555
}
519556
int main(int argc, char** argv)
520557
{
@@ -533,26 +570,20 @@ int main(int argc, char** argv)
533570

534571
MQ_Register();
535572
MQ_Authorize();
536-
if (argc > 1)
573+
MQ_Create();
574+
for (int i = 0; i < 10; i++)
537575
{
538-
MQ_Create();
539-
MQ_Subscribe();
540-
}
541-
else
542-
{
543-
MQ_Create();
544-
for (int i = 0; i < 1000; i++)
545-
{
546-
MQ_Post(lpszMsgBuffer);
547-
}
548-
MQ_GetSerial();
549-
MQ_GetNumber();
550-
MQ_Get();
551-
MQ_Get();
552-
MQ_Get();
553-
MQ_DeleteTopic();
554-
MQ_DeleteUser();
576+
MQ_Post(lpszMsgBuffer);
555577
}
578+
MQ_GetSerial();
579+
MQ_GetNumber();
580+
MQ_Get();
581+
MQ_Get();
582+
MQ_Get();
583+
MQ_Subscribe();
584+
MQ_TimePublish();
585+
MQ_DeleteTopic();
586+
MQ_DeleteUser();
556587

557588
XClient_TCPSelect_Close(m_Socket);
558589
#ifdef _WINDOWS

XEngine_Docment/Docment_en.docx

-4.65 KB
Binary file not shown.

XEngine_Docment/Docment_zh.docx

-4.36 KB
Binary file not shown.

XEngine_Release/XEngine_Config/XEngine_Config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
"nHttpPort":5201,
77
"nWSPort":5202,
88
"nRPCPort":5203,
9-
"nBroadRVPort":5210,
10-
"nBroadSDPort":5211,
119
"XMax":{
1210
"nMaxClient":10000,
1311
"nMaxQueue":10000,
@@ -32,6 +30,7 @@
3230
"SQLPass":"123123Ruiyue"
3331
},
3432
"XVer":[
33+
"3.3.0.1001 Build20220805",
3534
"3.2.0.1001 Build20220715",
3635
"3.1.0.1001 Build20220408",
3736
"3.0.0.1001 Build20220318",

XEngine_SQLFile/XEngine_MQData.sql

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
44
Source Server : Test
55
Source Server Type : MySQL
6-
Source Server Version : 80028
6+
Source Server Version : 80030
77
Source Host : 192.168.1.12:3306
88
Source Schema : XEngine_MQData
99
1010
Target Server Type : MySQL
11-
Target Server Version : 80028
11+
Target Server Version : 80030
1212
File Encoding : 65001
1313
14-
Date: 01/04/2022 11:30:02
14+
Date: 01/08/2022 13:15:31
1515
*/
1616

1717
SET NAMES utf8mb4;
@@ -23,15 +23,25 @@ SET FOREIGN_KEY_CHECKS = 0;
2323
DROP TABLE IF EXISTS `XEngine_CommKey`;
2424
CREATE TABLE `XEngine_CommKey` (
2525
`ID` int NOT NULL AUTO_INCREMENT,
26-
`tszQueueName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '所属队列',
26+
`tszQueueName` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '所属队列',
2727
`nQueueSerial` bigint NOT NULL COMMENT '消息序列',
2828
`nQueueGetTime` bigint NOT NULL COMMENT '获取次数',
29-
`tszQueueLeftTime` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '过期时间',
30-
`tszQueuePublishTime` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '发布时间',
31-
`tszQueueData` varchar(8192) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '保存数据',
29+
`tszQueueLeftTime` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '过期时间',
30+
`tszQueuePublishTime` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '发布时间',
31+
`tszQueueData` varchar(8192) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '保存数据',
3232
`nDataLen` int NOT NULL COMMENT '数据大小',
3333
`tszQueueCreateTime` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '插入时间',
3434
PRIMARY KEY (`ID`) USING BTREE
35-
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
35+
) ENGINE = InnoDB CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;
36+
37+
-- ----------------------------
38+
-- Table structure for XEngine_TimeRelease
39+
-- ----------------------------
40+
DROP TABLE IF EXISTS `XEngine_TimeRelease`;
41+
CREATE TABLE `XEngine_TimeRelease` (
42+
`tszQueueName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '队列名称',
43+
`nIDMsg` bigint NOT NULL COMMENT '队列唯一ID',
44+
`nIDTime` bigint NOT NULL COMMENT '发布时间'
45+
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
3646

3747
SET FOREIGN_KEY_CHECKS = 1;

XEngine_Source/MQCore_ConfigModule/Config_Define.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ typedef struct tag_XEngine_ServerConfig
2121
int nTCPPort;
2222
int nHttpPort;
2323
int nWSPort;
24-
int nBroadRVPort;
25-
int nBroadSDPort;
2624
struct
2725
{
2826
int nMaxClient;

XEngine_Source/MQCore_ConfigModule/Config_Json/Config_Json.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile,XENGINE_SERVERCONFIG
6969
pSt_ServerConfig->nTCPPort = st_JsonRoot["nTCPPort"].asInt();
7070
pSt_ServerConfig->nHttpPort = st_JsonRoot["nHttpPort"].asInt();
7171
pSt_ServerConfig->nWSPort = st_JsonRoot["nWSPort"].asInt();
72-
pSt_ServerConfig->nBroadRVPort = st_JsonRoot["nBroadRVPort"].asInt();
73-
pSt_ServerConfig->nBroadSDPort = st_JsonRoot["nBroadSDPort"].asInt();
7472

7573
if (st_JsonRoot["XMax"].empty() || (6 != st_JsonRoot["XMax"].size()))
7674
{

0 commit comments

Comments
 (0)