Skip to content

Commit cf50204

Browse files
committed
added:message attr add proactive message get.
modify:some issues with message identification will be handled when obtaining the specified message
1 parent fd3a1b9 commit cf50204

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
330330
time_t nTimeStart = time(NULL);
331331
time_t nTimeEnd = nTimeStart + st_MQProtocol.nKeepTime;
332332
BaseLib_OperatorTimeSpan_CalForTime(nTimeStart, nTimeEnd, &st_LibTime);
333-
_xstprintf(st_DBQueue.tszQueueLeftTime, _X("%04d-%02d-%02d %02d:%02d:%02d"), st_LibTime.wYear, st_LibTime.wMonth, st_LibTime.wDay, st_LibTime.wHour, st_LibTime.wMinute, st_LibTime.wSecond);
333+
BaseLib_OperatorTime_TimeToStr(st_DBQueue.tszQueueLeftTime, NULL, true, &st_LibTime);
334334
}
335335
//处理序列号
336336
if (st_DBQueue.nQueueSerial > 0)
@@ -495,6 +495,51 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
495495
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError());
496496
return false;
497497
}
498+
//获得此消息属性
499+
XENGINE_PROTOCOL_MSGATTR st_MSGAttr = {};
500+
memcpy(&st_MSGAttr, &st_MessageQueue.nMsgAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
501+
//所属用户
502+
if (_tcsxlen(st_MessageQueue.tszUserBelong) > 0)
503+
{
504+
if (1 != st_MSGAttr.byAttrActive)
505+
{
506+
pSt_ProtocolHdr->wReserve = 723;
507+
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
508+
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
509+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:此消息不属于此用户"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial);
510+
return false;
511+
}
512+
}
513+
//过期任务
514+
if (_tcsxlen(st_MessageQueue.tszQueueLeftTime) > 2)
515+
{
516+
//有过期时间,判断是否过期
517+
__int64x nTimeRet = 0;
518+
XCHAR tszTimeStr[MAX_PATH] = {};
519+
BaseLib_OperatorTime_TimeToStr(tszTimeStr);
520+
BaseLib_OperatorTimeSpan_GetForStr(st_MessageQueue.tszQueueLeftTime, tszTimeStr, &nTimeRet, 3);
521+
//如果超时并且不允许主动获取,返回错误
522+
if ((nTimeRet < 0) && (1 != st_MSGAttr.byAttrActive))
523+
{
524+
pSt_ProtocolHdr->wReserve = 724;
525+
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
526+
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
527+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:消息超时"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial);
528+
return false;
529+
}
530+
}
531+
//定时发布任务
532+
if (_tcsxlen(st_MessageQueue.tszQueuePublishTime) > 0)
533+
{
534+
if (1 != st_MSGAttr.byAttrActive)
535+
{
536+
pSt_ProtocolHdr->wReserve = 725;
537+
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
538+
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
539+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,主题:%s,获取消息数据失败,获取指定消息序列:%lld 失败,错误:此为定时发布任务"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial);
540+
return false;
541+
}
542+
}
498543
}
499544
else
500545
{

XEngine_Source/XQueue_ProtocolHdr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
#pragma pack(1)
5656
typedef struct
5757
{
58-
XBYTE byAttrAll : 1; //通知所有
58+
XBYTE byAttrAll : 1; //通知所有,不限主题,仅在线列表有效
5959
XBYTE byAttrSelf : 1; //自己也能接受
6060
XBYTE byAttrReply : 1; //对方必须回复
61-
XBYTE byAttrResver3 : 1;
61+
XBYTE byAttrActive : 1; //主动获取不受限制,比如超时的,不是自己发给自己的
6262
XBYTE byAttrResver4 : 1;
6363
XBYTE byAttrResver5 : 1;
6464
XBYTE byAttrResver6 : 1;

0 commit comments

Comments
 (0)