Skip to content

Commit 2ff7fcc

Browse files
committed
modify:tcp task handle http type support
1 parent f3d9a40 commit 2ff7fcc

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Packet/ProtocolModule_Packet.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_Common(int nNetType, XENGINE_
7575
{
7676
ProtocolModule_Packet_WSCommon(pSt_ProtocolHdr, pSt_MQProtocol, ptszMsgBuffer, pInt_MsgLen, lpszMsgBuffer, nMsgLen);
7777
}
78+
else if (XENGINE_MQAPP_NETTYPE_HTTP == nNetType)
79+
{
80+
ProtocolModule_Packet_Http(ptszMsgBuffer, pInt_MsgLen, pSt_ProtocolHdr->wReserve);
81+
}
7882
else
7983
{
8084
ProtocolModule_Packet_MQTTCommon(pSt_ProtocolHdr, pSt_MQProtocol, ptszMsgBuffer, pInt_MsgLen, lpszMsgBuffer, nMsgLen);

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
4949
{
5050
lpszClientType = _X("WEBSOCKET");
5151
}
52+
else if (XENGINE_MQAPP_NETTYPE_HTTP == nNetType)
53+
{
54+
lpszClientType = _X("HTTP");
55+
}
5256
else
5357
{
5458
lpszClientType = _X("MQTT");
@@ -193,20 +197,27 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
193197
}
194198
else if (ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ == pSt_ProtocolHdr->unOperatorType)
195199
{
196-
XENGINE_PROTOCOL_XMQ st_MQProtocol;
197-
XCHAR tszUserName[MAX_PATH];
198-
199-
memset(&st_MQProtocol, '\0', sizeof(XENGINE_PROTOCOL_XMQ));
200-
memset(tszUserName, '\0', MAX_PATH);
201-
202-
if (!SessionModule_Client_GetUser(lpszClientAddr, tszUserName))
200+
XCHAR tszUserName[MAX_PATH] = {};
201+
XENGINE_PROTOCOL_XMQ st_MQProtocol = {};
202+
//根据协议处理
203+
if (XENGINE_MQAPP_NETTYPE_HTTP == nNetType)
203204
{
204-
pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_NOTLOGIN;
205-
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
206-
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
207-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求失败,用户没有通过验证"), lpszClientType, lpszClientAddr);
208-
return false;
205+
XENGINE_PROTOCOL_USERINFO st_UserInfo = {};
206+
Session_Token_Get(pSt_ProtocolHdr->xhToken, &st_UserInfo);
207+
_tcsxcpy(tszUserName, st_UserInfo.tszUserName);
209208
}
209+
else
210+
{
211+
if (!SessionModule_Client_GetUser(lpszClientAddr, tszUserName))
212+
{
213+
pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_AUTH_NOTLOGIN;
214+
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
215+
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
216+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求失败,用户没有通过验证"), lpszClientType, lpszClientAddr);
217+
return false;
218+
}
219+
}
220+
210221
if (nMsgLen >= (int)sizeof(XENGINE_PROTOCOL_XMQ))
211222
{
212223
memcpy(&st_MQProtocol, lpszMsgBuffer, sizeof(XENGINE_PROTOCOL_XMQ));
@@ -590,10 +601,12 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
590601
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
591602
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
592603
}
604+
BaseLib_Memory_Free((XPPPMEM)&ppszTableName, nListCount);
593605
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,创建主题失败,主题名称:%s,主题存在,无法继续"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey);
594606
return false;
595607
}
596608
}
609+
BaseLib_Memory_Free((XPPPMEM)&ppszTableName, nListCount);
597610
//创建表
598611
if (!DBModule_MQData_CreateTable(st_MQProtocol.tszMQKey))
599612
{

0 commit comments

Comments
 (0)