Skip to content

Commit d34d603

Browse files
committed
added:register bind comm topic
1 parent 6164156 commit d34d603

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

XEngine_Apps/MQCore_TCPApp/MQCore_TCPApp.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ using namespace std;
2424

2525
XSOCKET m_Socket;
2626
__int64x nLastNumber = 0;
27-
LPCXSTR lpszKey = _X("XEngine_NotifyKey"); //主题
27+
LPCXSTR lpszKey = _X("XEngine_CommKey"); //主题
28+
LPCXSTR lpszUser = _X("aaadddzxc");
29+
LPCXSTR lpszPass = _X("123123");
2830

2931
void MQ_Register()
3032
{
@@ -48,8 +50,8 @@ void MQ_Register()
4850
st_ProtocolInfo.nUserState = 0;
4951
st_ProtocolInfo.nPhoneNumber = 13699999999;
5052
st_ProtocolInfo.nIDNumber = 511000000000101010;
51-
strcpy(st_ProtocolInfo.tszUserName, "123123aa");
52-
strcpy(st_ProtocolInfo.tszUserPass, "123123");
53+
strcpy(st_ProtocolInfo.tszUserName, lpszUser);
54+
strcpy(st_ProtocolInfo.tszUserPass, lpszPass);
5355
strcpy(st_ProtocolInfo.tszEMailAddr, "[email protected]");
5456

5557
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_USERINFO);
@@ -95,8 +97,8 @@ void MQ_Authorize()
9597
st_ProtocolHdr.byIsReply = true; //获得处理返回结果
9698
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
9799

98-
strcpy(st_ProtocolAuth.tszUserName, "123123aa");
99-
strcpy(st_ProtocolAuth.tszUserPass, "123123");
100+
strcpy(st_ProtocolAuth.tszUserName, lpszUser);
101+
strcpy(st_ProtocolAuth.tszUserPass, lpszPass);
100102

101103
st_ProtocolHdr.unPacketSize = sizeof(XENGINE_PROTOCOL_USERAUTH);
102104

@@ -199,8 +201,8 @@ void MQ_DeleteUser()
199201
st_ProtocolInfo.nUserState = 0;
200202
st_ProtocolInfo.nPhoneNumber = 13699999999;
201203
st_ProtocolInfo.nIDNumber = 511000000000101010;
202-
strcpy(st_ProtocolInfo.tszUserName, "123123aa");
203-
strcpy(st_ProtocolInfo.tszUserPass, "123123");
204+
strcpy(st_ProtocolInfo.tszUserName, lpszUser);
205+
strcpy(st_ProtocolInfo.tszUserPass, lpszPass);
204206
strcpy(st_ProtocolInfo.tszEMailAddr, "[email protected]");
205207

206208
nLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"MQUser":{
3-
"UserTime":{
4-
"bPubClear":false
2+
"MQUser": {
3+
"UserTime": {
4+
"bPubClear": false
55
}
66
},
7-
"MQData":{
8-
"nDBMonth":3
7+
"MQData": {
8+
"bCommSub": true,
9+
"nDBMonth": 3
910
}
1011
}

XEngine_Source/MQCore_ConfigModule/Config_Define.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef struct
7878
struct
7979
{
8080
int nDBMonth;
81+
bool bCommSub;
8182
}st_MQData;
8283
}MESSAGEQUEUE_DBCONFIG;
8384
//////////////////////////////////////////////////////////////////////////

XEngine_Source/MQCore_ConfigModule/Config_Json/Config_Json.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,14 @@ bool CConfig_Json::Config_Json_DBFile(LPCXSTR lpszConfigFile, MESSAGEQUEUE_DBCON
250250
Json::Value st_JsonUserTime = st_JsonUser["UserTime"];
251251
pSt_DBConfig->st_MQUser.st_UserTime.bPubClear = st_JsonUserTime["bPubClear"].asBool();
252252

253-
if (st_JsonRoot["MQData"].empty() || (1 != st_JsonRoot["MQData"].size()))
253+
if (st_JsonRoot["MQData"].empty() || (2 != st_JsonRoot["MQData"].size()))
254254
{
255255
Config_IsErrorOccur = true;
256256
Config_dwErrorCode = ERROR_MQ_MODULE_CONFIG_JSON_XTIME;
257257
return false;
258258
}
259259
Json::Value st_JsonMQData = st_JsonRoot["MQData"];
260260
pSt_DBConfig->st_MQData.nDBMonth = st_JsonMQData["nDBMonth"].asInt();
261+
pSt_DBConfig->st_MQData.bCommSub = st_JsonMQData["bCommSub"].asBool();
261262
return true;
262263
}

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,20 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
227227
return false;
228228
}
229229
}
230+
//是否需要订阅公用消息队列
231+
if (st_DBConfig.st_MQData.bCommSub)
232+
{
233+
XENGINE_DBUSERKEY st_Userkey;
234+
memset(&st_Userkey, '\0', sizeof(XENGINE_DBUSERKEY));
235+
236+
_tcsxcpy(st_Userkey.tszUserName, st_UserInfo.tszUserName);
237+
_tcsxcpy(st_Userkey.tszKeyName, st_ServiceCfg.tszTopic);
238+
//创建
239+
if (!DBModule_MQUser_KeyInsert(&st_Userkey))
240+
{
241+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("%s消息端:%s,绑定消息队列主题失败,主题名称:%s,错误:%lX"), lpszClientType, lpszClientAddr, st_Userkey.tszKeyName, DBModule_GetLastError());
242+
}
243+
}
230244
pSt_ProtocolHdr->wReserve = 0;
231245
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen);
232246
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);

0 commit comments

Comments
 (0)