...
 
Commits (18)
    https://gitcode.net/xengine/XEngine_MQService/-/commit/8ceac0d83b08cb3532f44526f1d2759449611751 update:xengine match v8.15 2023-08-11T10:43:50+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/ade752c640d35dd54f2fd33aabf0e7178ab6905f modify:Prevent users from logging in repeatedly 2023-08-11T11:19:07+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/c4150a00b14f6b75445b426e5b19f0f4212f5db3 modify:saved user info table for session module when client create 2023-08-11T11:40:24+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/bfce24ac453ed3d1f22e8e72cd7926f0106a68a9 added:unsubscribe message supported 2023-08-11T13:49:15+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/f4357f2350e79dbd09c3c5e002dacf2c5d701ba1 update:http client function is removed 2023-08-11T14:01:31+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/d413cc4837f9a706a8d36205b82071ef15a0e1df added:http modify to management api and added get user list support 2023-08-11T15:08:17+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/8518ee366c878b86ceaa6f6eb91df13907d8221e added:get topic list for http api 2023-08-15T11:31:49+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/69e1cfd9fe22caa45d6614171e39c98f8e6e6847 added:binary support for protocol module json 2023-08-15T13:51:53+08:00 qyt 486179@qq.com modify:ProtocolModule_Parse_http to ProtocolModule_Parse_Websocket https://gitcode.net/xengine/XEngine_MQService/-/commit/187c0c7dcf469cce88702a05c191d4ee4b707ef9 last modify merge 2023-08-15T13:52:57+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/962b5dbc368a2ed2cbd917e0ebff3d554b22377e delete:unused code 2023-08-15T13:53:50+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/797a143d67c96223987b43e8044bf3a459ee029a modify:ProtocolModule_Packet_HttpCommon to ProtocolModule_Packet_WSCommon fun... 2023-08-15T14:20:51+08:00 qyt 486179@qq.com modify:ProtocolModule_Packet_WSCommon support bin coder to base64 https://gitcode.net/xengine/XEngine_MQService/-/commit/65a52491c9f209c0dea5ca8e7dcf10ed66fce7be fixed:the problem that websocket parse have not byIsReply flag 2023-08-15T14:49:57+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/6d91a1f4b295ca5445e42e95dd72bac338366361 delete:unused http code 2023-08-15T14:58:40+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/452c68f075f97fe9a07fe878a18aabd3349e7497 update:exmaple 2023-08-15T15:00:14+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/d7e0f789e9f1bbdce2932a5fa2f831175ac5de06 update:configure file 2023-08-16T09:58:01+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/eb650773eb1190061fa5305e679b2004d99cdb71 fixed:linux build error 2023-08-16T09:59:47+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/0efd89aabaca9d483d1d644e7cf16dd31adb5bc1 update:readme and docment 2023-08-16T10:00:10+08:00 qyt 486179@qq.com https://gitcode.net/xengine/XEngine_MQService/-/commit/5adab207225f4c0996be62658d54ac7cec83bc95 !20 V3.8.0.1001 Merge 2023-08-16T02:04:28+00:00 qyt 486179@qq.com Merge pull request !20 from qyt/develop
XEngine_MQService V3.8.0.1001
增加:websocket的二进制消息负载能力支持
增加:HTTP管理接口功能
增加:HTTP接口获取用户列表
增加:HTTP接口获取主题列表
增加:取消订阅消息支持
更新:匹配支持XEngine V8.15版本
更新:不在支持HTTP客户端了
修改:禁止用户重复登录
修改:会话模块保存用户信息的时候会保存整个用户表了
修改:ProtocolModule_Parse_http 为 ProtocolModule_Parse_Websocket 函数名
修改:ProtocolModule_Packet_HttpCommon 为 ProtocolModule_Packet_WSCommon 函数名
修正:websocket协议解析没有byIsReply 字段解析的问题
added:binary message payload supported for websocket
added:unsubscribe message supported
added:http management interface functions
added:get user list for http api
added:get topic list for http api
update:xengine match v8.15
update:http client function is removed
modify:Prevent users from logging in repeatedly
modify:saved user info table for session module when client create
modify:ProtocolModule_Parse_http to ProtocolModule_Parse_Websocket function name
modify:ProtocolModule_Packet_HttpCommon to ProtocolModule_Packet_WSCommon function name
fixed:the problem that websocket parse have not byIsReply flag
======================================================================================
XEngine_MQService V3.7.0.1001
添加:定时发布是否跳过本身功能
......
......@@ -24,18 +24,19 @@ this software support following features
8. message get time
9. message subcribe
10. support Permission Validation
11. support multi protocol(TCP,HTTP,WEBSOCKET)
11. support multi protocol(TCP,WEBSOCKET)
12. Active delivery acquisition mode or passive subscription notification module
13. get order and start serial pos setting
14. Unlimited load message types
15. timed message
16. Access control(planning)
17. binary message(only tcp)
17. binary message
18. http interface management
## install
#### XEngine Evn
you must install XEngine,need V8.10 or above,install XEngine can be refer to xengine Readme docment
you must install XEngine,need V8.15 or above,install XEngine can be refer to xengine Readme docment
GITEE:https://gitee.com/xyry/libxengine
GITHUB:https://github.com/libxengine/xengine
......@@ -95,7 +96,7 @@ database you need to open the database matching fields and tables are consistent
You can refer to the document under the docment directory. It contains API protocol and service description.
## Test Server Address
Address:app.xyry.org Port:TCP 5200,HTTP 5201,WEBSOCKET 5202
Address:app.xyry.org Port:TCP 5200,WEBSOCKET 5201,HTTP Management Interface 5202
## Participate in contribution
......
......@@ -23,18 +23,19 @@ c c++Message Service
8. 消息次数
9. 消息订阅
10. 支持权限验证
11. 支持多种协议(TCP,HTTP,WEBSOCKET)
11. 支持多种协议(TCP,WEBSOCKET)
12. 主动投递获取模式或者被动订阅通知模块
13. 获取顺序与开始序列号设置
14. 不限制负载的消息类型
15. 定时消息
16. 权限控制(planning)
17. 二进制消息(only tcp)
17. 二进制消息
18. http接口管理
## 安装教程
#### XEngine环境
必须安装XEngine,版本需要V8.10或者以上版本,安装XEngine可以参考其Readme文档
必须安装XEngine,版本需要V8.15或者以上版本,安装XEngine可以参考其Readme文档
GITEE:https://gitee.com/xyry/libxengine
GITHUB:https://github.com/libxengine/xengine
......@@ -101,7 +102,7 @@ make FLAGS=CleanAll 清理编译
你可以参考docment目录下的文档.里面包含了API协议和服务说明.
## 测试服务器
地址:app.xyry.org 端口:TCP 5200,HTTP 5201,WEBSOCKET 5202
地址:app.xyry.org 端口:TCP 5200,WEBSOCKET 5201,管理接口HTTP 5202
## 参与贡献
......@@ -126,10 +127,8 @@ MQTT支持
支持时区设置
完善消息订阅(永存)
完善HTTP_CALL
允许主题解除绑定
允许删除主题
高性能内存队列
多次登录验证
扩充HTTP管理接口
## 提交问题
......
......@@ -21,312 +21,32 @@
#include "../../XEngine_Source/XQueue_ProtocolHdr.h"
//g++ -std=c++17 -Wall -g MQCore_HTTPApp.cpp -o MQCore_HTTPApp.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp -Wl,-rpath=../../XEngine_Source/XEngine_ThirdPart/jsoncpp,--disable-new-dtags
XSOCKET m_Socket;
XNETHANDLE xhToken = 0;
LPCXSTR lpszKey = _X("XEngine_Notify"); //主题
LPCXSTR lpszPostUrl = _X("http://127.0.0.1:5201");
void MQ_Authorize()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonAuth;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUSERLOG;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonAuth["tszUserName"] = "123123aa";
st_JsonAuth["tszUserPass"] = "123123";
st_JsonRoot["st_Auth"] = st_JsonAuth;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody, &nLen))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_Authorize:%s\n", ptszMsgBody);
JSONCPP_STRING st_JsonError;
Json::CharReaderBuilder st_ReaderBuilder;
st_JsonRoot.clear();
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_ReaderBuilder.newCharReader());
if (!pSt_JsonReader->parse(ptszMsgBody, ptszMsgBody + nLen, &st_JsonRoot, &st_JsonError))
{
return;
}
if (!st_JsonRoot["xhToken"].isNull())
{
xhToken = st_JsonRoot["xhToken"].asUInt64();
}
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_UNRead()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUNREAD;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["tszMQKey"] = ""; //所有未读
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_UNRead:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_Create()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICCREATE;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_Create:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_Post(LPCXSTR lpszMsgBuffer)
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQPOST;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_STRING;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonMQProtocol["nSerial"] = 0; //序列号,0服务会自动处理
st_JsonMQProtocol["nKeepTime"] = -1; //保存时间,单位秒,如果为0,获取一次后被抛弃。-1 永久存在,PacketKey不能为空
st_JsonMQProtocol["nGetTimer"] = 0;
st_JsonPayload["nPayType"] = 0;
st_JsonPayload["nPayLen"] = (Json::Value::UInt)strlen(lpszMsgBuffer);
st_JsonPayload["tszPayData"] = lpszMsgBuffer;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
st_JsonRoot["st_Payload"] = st_JsonPayload;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_Post:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_BindTopic()
void MQ_GetUserList()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
LPCXSTR lpszPostUrl = _X("http://127.0.0.1:5202/api?function=get&method=user");
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICBIND;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["nSerial"] = 1; //设置为1开始读取
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_GetNumber:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_Get()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQGET;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_Get:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_ModifyMsg()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQMSGMODIFY;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonMQProtocol["nSerial"] = 1; //序列号
st_JsonMQProtocol["nKeepTime"] = -1;
st_JsonMQProtocol["nGetTimer"] = 0;
st_JsonPayload["nPayType"] = 0;
st_JsonPayload["nPayLen"] = 6;
st_JsonPayload["tszPayData"] = "modify";
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
st_JsonRoot["st_Payload"] = st_JsonPayload;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
if (!APIClient_Http_Request(_X("GET"), lpszPostUrl, NULL, NULL, &ptszMsgBody, &nLen))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_ModifyMsg:%s\n", ptszMsgBody);
_xtprintf("MQ_GetUserList:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_ModifyTopic()
void MQ_GetTopicList()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICMODIFY;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonPayload["nPayType"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_STRING;
st_JsonPayload["nPayLen"] = (Json::Value::UInt)strlen("XEngine_Modify");
st_JsonPayload["tszPayData"] = "XEngine_Modify";
LPCXSTR lpszPostUrl = _X("http://127.0.0.1:5202/api?function=get&method=topic");
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
st_JsonRoot["st_Payload"] = st_JsonPayload;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_ModifyTopic:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
void MQ_Delete()
{
int nLen = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICDELETE;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)xhToken;
st_JsonMQProtocol["tszMQKey"] = "XEngine_Modify";
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
nLen = st_JsonRoot.toStyledString().length();
memcpy(tszMsgBuffer, st_JsonRoot.toStyledString().c_str(), nLen);
XCHAR* ptszMsgBody = NULL;
if (!APIClient_Http_Request(_X("POST"), lpszPostUrl, tszMsgBuffer, NULL, &ptszMsgBody))
if (!APIClient_Http_Request(_X("GET"), lpszPostUrl, NULL, NULL, &ptszMsgBody, &nLen))
{
_xtprintf("发送投递失败!\n");
return;
}
_xtprintf("MQ_Delete:%s\n", ptszMsgBody);
_xtprintf("MQ_GetTopicList:%s\n", ptszMsgBody);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBody);
}
......@@ -337,15 +57,8 @@ int main()
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
#endif
MQ_Authorize();
MQ_UNRead();
MQ_Create();
MQ_Post("123hello");
MQ_BindTopic();
MQ_Get();
MQ_ModifyMsg();
MQ_ModifyTopic();
MQ_Delete();
MQ_GetUserList();
MQ_GetTopicList();
#ifdef _MSC_BUILD
WSACleanup();
......
......@@ -16,6 +16,7 @@
#include <XEngine_Include/XEngine_ProtocolHdr.h>
#include <XEngine_Include/XEngine_Client/XClient_Define.h>
#include <XEngine_Include/XEngine_Client/XClient_Error.h>
#include <XEngine_Include/XEngine_Core/ManagePool_Define.h>
#include <XEngine_Include/XEngine_RfcComponents/WSProtocol_Define.h>
#include <XEngine_Include/XEngine_RfcComponents/WSProtocol_Error.h>
#include "../../XEngine_Source/XQueue_ProtocolHdr.h"
......@@ -107,6 +108,7 @@ void MQ_Create()
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICCREATE;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["byIsReply"] = 1;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonMQProtocol["nSerial"] = 0;
......@@ -144,14 +146,14 @@ void MQ_Post(LPCXSTR lpszMsgBuffer)
Json::Value st_JsonPayload;
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQPOST;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_STRING;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_BIN;
st_JsonRoot["byIsReply"] = 1;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonMQProtocol["nSerial"] = 0; //序列号,0服务会自动处理
st_JsonMQProtocol["nKeepTime"] = -1; //保存时间,单位秒,如果为0,获取一次后被抛弃。-1 永久存在,PacketKey不能为空
st_JsonMQProtocol["nGetTimer"] = 0;
st_JsonPayload["nPayType"] = 0;
st_JsonPayload["nPayLen"] = (Json::Value::UInt)strlen(lpszMsgBuffer);
st_JsonPayload["tszPayData"] = lpszMsgBuffer;
......@@ -189,9 +191,10 @@ void MQ_BindTopic()
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICBIND;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["byIsReply"] = 1;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonMQProtocol["nSerial"] = 10;
st_JsonMQProtocol["nSerial"] = 1;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
......@@ -225,6 +228,7 @@ void MQ_GetNumber()
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQNUMBER;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["byIsReply"] = 1;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
......@@ -259,6 +263,7 @@ void MQ_Get()
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQGET;
st_JsonRoot["byVersion"] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
st_JsonRoot["byIsReply"] = 1;
st_JsonMQProtocol["tszMQKey"] = lpszKey;
st_JsonMQProtocol["nSerial"] = 0;
......@@ -297,12 +302,12 @@ int main()
memset(tszKeyBuffer, '\0', sizeof(tszKeyBuffer));
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
if (!RfcComponents_WSConnector_Connect(tszKeyBuffer, tszMsgBuffer, &nLen, "127.0.0.1:5202"))
if (!RfcComponents_WSConnector_Connect(tszKeyBuffer, tszMsgBuffer, &nLen))
{
_xtprintf("RfcComponents_WSConnector_Connect:%lX", WSFrame_GetLastError());
return -1;
}
if (!XClient_TCPSelect_Create(&m_Socket, _X("127.0.0.1"), 5202))
if (!XClient_TCPSelect_Create(&m_Socket, _X("127.0.0.1"), 5201))
{
_xtprintf("NetClient_TCPSelect_Create:%lX", XClient_GetLastError());
return -1;
......@@ -333,7 +338,7 @@ int main()
}
MQ_Authorize();
MQ_Create();
MQ_Post("123hello");
MQ_Post("MTIzMTIz");
MQ_GetNumber();
MQ_BindTopic();
MQ_Get();
......
copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_BaseLib.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_Algorithm.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_OPenSsl.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_ManagePool.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_RfcComponents\RfcComponents_WSProtocol.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_NetHelp\NetHelp_APIClient.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_Client\XClient_Socket.dll" "./"
......
......@@ -2,6 +2,12 @@
100:HTTP/1.1 100 Continue
101:HTTP/1.1 101 Switching Protocols
102:HTTP/1.1 102 Processing
103:HTTP/1.1 103 Early Hints
110:HTTP/1.1 110 (obsoleted) Response is Stale
111:HTTP/1.1 111 (obsoleted) Revalidation Failed
112:HTTP/1.1 112 (obsoleted) Disconnected Operation
113:HTTP/1.1 113 (obsoleted) Heuristic Expiration
199:HTTP/1.1 199 (obsoleted) Miscellaneous Warning
//CodeSuccess
200:HTTP/1.1 200 OK
201:HTTP/1.1 201 Created
......@@ -10,18 +16,25 @@
204:HTTP/1.1 204 No Content
205:HTTP/1.1 205 Reset Content
206:HTTP/1.1 206 Partial Content
207:HTTP/1.1 207 Multi-Status
208:HTTP/1.1 208 Already Reported
214:HTTP/1.1 214 (obsoleted) Transformation Applied
226:HTTP/1.1 226 IM Used
299:HTTP/1.1 299 (obsoleted) Miscellaneous Persistent Warning
//CodeRedirect
300:HTTP/1.1 300 Multiple Choices
301:HTTP/1.1 301 Moved Permanently
302:HTTP/1.1 302 Move temporarily
302:HTTP/1.1 302 Moved temporarily
303:HTTP/1.1 303 See Other
304:HTTP/1.1 304 Not Modified
305:HTTP/1.1 305 Use Proxy
306:HTTP/1.1 306 Switch Proxy
307:HTTP/1.1 307 Temporary Redirect
308:HTTP/1.1 308 Permanent Redirect
//CodeRequestFail
400:HTTP/1.1 400 Bad Request
401:HTTP/1.1 401 Payment Required
402:HTTP/1.1 402 Unauthorized
401:HTTP/1.1 401 Unauthorized
402:HTTP/1.1 402 Payment Required
403:HTTP/1.1 403 Forbidden
404:HTTP/1.1 404 Not Found
405:HTTP/1.1 405 Method Not Allowed
......@@ -37,14 +50,32 @@
415:HTTP/1.1 415 Unsupported Media Type
416:HTTP/1.1 416 Requested Range Not Satisfiable
417:HTTP/1.1 417 Expectation Failed
418:HTTP/1.1 418 I'm a teapot
419:HTTP/1.1 419 (Unofficial) Page Expired
420:HTTP/1.1 420 (Unofficial) Method Failure
421:HTTP/1.1 421 too many connections
422:HTTP/1.1 422 Unprocessable Entity
423:HTTP/1.1 423 Locked
424:HTTP/1.1 424 Failed Dependency
425:HTTP/1.1 425 Unordered Collection
426:HTTP/1.1 426 Upgrade Required
449:HTTP/1.1 449 Retry With
451:HTTP/1.1 451 Unavailable For Legal Reasons
428:HTTP/1.1 428 Precondition Required
429:HTTP/1.1 429 Too Many Requests
430:HTTP/1.1 430 (Unofficial) Request Header Fields Too Large
431:HTTP/1.1 431 Request Header Fields Too Large
440:HTTP/1.1 440 (IIS) Login Time-out
444:HTTP/1.1 444 (nginx) No Response
449:HTTP/1.1 449 (IIS) Retry With
450:HTTP/1.1 450 (Unofficial) Blocked by Windows Parental Controls
451:HTTP/1.1 451 (IIS) Redirect
460:HTTP/1.1 460 (AWS)
463:HTTP/1.1 463 (AWS)
494:HTTP/1.1 494 (nginx) Request header too large
495:HTTP/1.1 495 (nginx) SSL Certificate Error
496:HTTP/1.1 496 (nginx) SSL Certificate Required
497:HTTP/1.1 497 (nginx) HTTP Request Sent to HTTPS Port
498:HTTP/1.1 498 (Unofficial) Invalid Token
499:HTTP/1.1 499 (nginx) Token Required
//CodeServerFail
500:HTTP/1.1 500 Internal Server Error
501:HTTP/1.1 501 Not Implemented
......@@ -54,8 +85,24 @@
505:HTTP/1.1 505 HTTP Version Not Supported
506:HTTP/1.1 506 Variant Also Negotiates
507:HTTP/1.1 507 Insufficient Storage
508:HTTP/1.1 509 Bandwidth Limit Exceeded
508:HTTP/1.1 508 Loop Detected
509:HTTP/1.1 509 (Unofficial) Bandwidth Limit Exceeded
510:HTTP/1.1 510 Not Extended
511:HTTP/1.1 511 Network Authentication Required
520:HTTP/1.1 520 (Cloudflare) Web Server Returned an Unknown Error
521:HTTP/1.1 521 (Cloudflare) Web Server Is Down
522:HTTP/1.1 522 (Cloudflare) Connection Timed Out
523:HTTP/1.1 523 (Cloudflare) Origin Is Unreachable
524:HTTP/1.1 524 (Cloudflare) A Timeout Occurred
525:HTTP/1.1 525 (Cloudflare) SSL Handshake Failed
526:HTTP/1.1 526 (Cloudflare) Invalid SSL Certificate
527:HTTP/1.1 527 (Cloudflare) Railgun Error
529:HTTP/1.1 529 (Unofficial) Site is overloaded
530:HTTP/1.1 530 (Cloudflare) Site is frozen
561:HTTP/1.1 561 (AWS) Unauthorized
598:HTTP/1.1 598 (Unofficial) Network read timeout error
599:HTTP/1.1 599 (Unofficial) Network Connect Timeout Error
600:HTTP/1.1 600 Unparseable Response Headers
//CodeUser
//XEngine Code
1001:HTTP/1.1 1001 XEngine Auth Ok
1002:HTTP/1.1 1002 XEngine Auth Failed
\ No newline at end of file
text/html html htm shtml
text/css css
text/xml xml
image/gif gif
image/jpeg jpeg jpg
application/javascript js
application/atom+xml atom
application/rss+xml rss
text/mathml mml
text/plain txt
text/vnd.sun.j2me.app-descriptor jad
text/vnd.wap.wml wml
text/x-component htc
image/gif gif
image/jpeg jpeg jpg
image/avif avif
image/png png
image/tiff tif tiff
image/webp webp
image/vnd.wap.wbmp wbmp
image/svg+xml svg svgz
image/x-icon ico
image/x-jng jng
image/x-ms-bmp bmp
image/svg+xml svg svgz
image/webp webp
application/font-woff woff
font/woff woff
font/woff2 woff2
application/pdf pdf
application/vnd.google-earth.kml+xml kml
application/vnd.google-earth.kmz kmz
application/msword doc
application/vnd.ms-excel xls
application/vnd.ms-powerpoint ppt
application/vnd.ms-fontobject eot
application/vnd.oasis.opendocument.graphics odg
application/vnd.oasis.opendocument.presentation odp
application/vnd.oasis.opendocument.spreadsheet ods
application/vnd.oasis.opendocument.text odt
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/javascript js
application/atom+xml atom
application/rss+xml rss
application/java-archive jar war ear
application/json json
application/mac-binhex40 hqx
application/msword doc
application/pdf pdf
application/postscript ps eps ai
application/rtf rtf
application/vnd.apple.mpegurl m3u8
application/vnd.ms-excel xls
application/vnd.ms-fontobject eot
application/vnd.ms-powerpoint ppt
application/vnd.wap.wmlc wmlc
application/vnd.google-earth.kml+xml kml
application/vnd.google-earth.kmz kmz
application/wasm wasm
application/x-7z-compressed 7z
application/x-cocoa cco
application/x-java-archive-diff jardiff
......@@ -62,10 +76,6 @@ application/octet-stream dmg
application/octet-stream iso img
application/octet-stream msi msp msm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
audio/midi mid midi kar
audio/mpeg mp3
audio/ogg ogg
......@@ -83,4 +93,4 @@ video/x-m4v m4v
video/x-mng mng
video/x-ms-asf asx asf
video/x-ms-wmv wmv
video/x-msvideo avi
video/x-msvideo avi
\ No newline at end of file
......@@ -3,8 +3,8 @@
"tszTopic":"XEngine_CommKey",
"bDeamon":0,
"nTCPPort":5200,
"nHttpPort":5201,
"nWSPort":5202,
"nWSPort":5201,
"nHttpPort":5202,
"XMax":{
"nMaxClient":10000,
"nMaxQueue":10000,
......@@ -14,8 +14,7 @@
"nWSThread":2
},
"XTime":{
"nDBMonth":3,
"nSessionTime":60
"nDBMonth":3
},
"XLog":{
"MaxSize":1024000,
......@@ -23,10 +22,10 @@
"LogLeave":32
},
"XSql":{
"SQLAddr":"42.194.178.57",
"SQLAddr":"10.0.3.155",
"SQLPort":3306,
"SQLUser":"root",
"SQLPass":"1111"
"SQLPass":"123123Qyt"
},
"XPass":{
"nTimeout":2,
......@@ -36,6 +35,7 @@
"tszPassLogout":""
},
"XVer":[
"3.8.0.1001 Build20230816",
"3.7.0.1001 Build20230426",
"3.6.0.1001 Build20230222",
"3.5.0.1001 Build20230106",
......
......@@ -33,7 +33,6 @@ typedef struct
struct
{
int nDBMonth;
int nSessionTime;
}st_XTime;
struct
{
......
......@@ -84,7 +84,7 @@ bool CConfig_Json::Config_Json_File(LPCXSTR lpszConfigFile,XENGINE_SERVERCONFIG
pSt_ServerConfig->st_XMax.nHttpThread = st_JsonXMax["nHttpThread"].asInt();
pSt_ServerConfig->st_XMax.nWSThread = st_JsonXMax["nWSThread"].asInt();
if (st_JsonRoot["XTime"].empty() || (2 != st_JsonRoot["XTime"].size()))
if (st_JsonRoot["XTime"].empty() || (1 != st_JsonRoot["XTime"].size()))
{
Config_IsErrorOccur = true;
Config_dwErrorCode = ERROR_MQ_MODULE_CONFIG_JSON_XTIME;
......@@ -92,7 +92,6 @@ bool CConfig_Json::Config_Json_File(LPCXSTR lpszConfigFile,XENGINE_SERVERCONFIG
}
Json::Value st_JsonXTime = st_JsonRoot["XTime"];
pSt_ServerConfig->st_XTime.nDBMonth = st_JsonXTime["nDBMonth"].asInt();
pSt_ServerConfig->st_XTime.nSessionTime = st_JsonXTime["nSessionTime"].asInt();
if (st_JsonRoot["XLog"].empty() || (3 != st_JsonRoot["XLog"].size()))
{
......
......@@ -233,6 +233,25 @@ extern "C" bool DBModule_MQData_DeleteTable(LPCXSTR lpszQueueName);
备注:
*********************************************************************/
extern "C" bool DBModule_MQData_ModifyTable(LPCXSTR lpszSrcTable, LPCXSTR lpszDstTable);
/********************************************************************
函数名称:DBModule_MQData_ShowTable
函数功能:获取所有表名
参数.一:pppszTableName
In/Out:Out
类型:三级指针
可空:N
意思:输出表名列表
参数.二:pInt_ListCount
In/Out:Out
类型:整数型指针
可空:N
意思:输出列表个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* pInt_ListCount);
/*************************************************************************
消息用户导出函数
**************************************************************************/
......@@ -325,6 +344,25 @@ extern "C" bool DBModule_MQUser_UserDelete(XENGINE_PROTOCOL_USERINFO * pSt_UserI
备注:
*********************************************************************/
extern "C" bool DBModule_MQUser_UserUPDate(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
/********************************************************************
函数名称:DBModule_MQUser_UserList
函数功能:获取用户列表
参数.一:pppSt_UserInfo
In/Out:Out
类型:三级指针
可空:N
意思:输出用户表信息
参数.二:pInt_ListCount
In/Out:Out
类型:整数型
可空:N
意思:输出用户表个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool DBModule_MQUser_UserList(XENGINE_PROTOCOL_USERINFO*** pppSt_UserInfo, int* pInt_ListCount);
/*************************************************************************
消息绑定导出函数
**************************************************************************/
......
......@@ -684,5 +684,68 @@ bool CDBModule_MQData::DBModule_MQData_ModifyTable(LPCXSTR lpszSrcTable, LPCXSTR
return false;
}
return true;
}
/********************************************************************
函数名称:DBModule_MQData_ShowTable
函数功能:获取所有表名
参数.一:pppszTableName
In/Out:Out
类型:三级指针
可空:N
意思:输出表名列表
参数.二:pInt_ListCount
In/Out:Out
类型:整数型指针
可空:N
意思:输出列表个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CDBModule_MQData::DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* pInt_ListCount)
{
DBModule_IsErrorOccur = false;
if (NULL == pInt_ListCount)
{
DBModule_IsErrorOccur = true;
DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_PARAMENT;
return false;
}
//查询
XNETHANDLE xhTable = 0;
__int64u nllLine = 0;
__int64u nllRow = 0;
XCHAR tszSQLStatement[1024];
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
//名称为,消息名为必填
_xstprintf(tszSQLStatement, _X("SHOW TABLES"));
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nllLine, &nllRow))
{
DBModule_IsErrorOccur = true;
DBModule_dwErrorCode = DataBase_GetLastError();
return false;
}
if (nllLine <= 0)
{
DBModule_IsErrorOccur = true;
DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_EMPTY;
return false;
}
*pInt_ListCount = (int)nllLine;
BaseLib_OperatorMemory_Malloc((XPPPMEM)pppszTableName, (int)nllLine, sizeof(XENGINE_DBMESSAGEQUEUE));
for (__int64u i = 0; i < nllLine; i++)
{
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
if (NULL != pptszResult[0])
{
_tcsxcpy((*pppszTableName)[i], pptszResult[0]);
}
}
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
return true;
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ public:
bool DBModule_MQData_CreateTable(LPCXSTR lpszQueueName);
bool DBModule_MQData_DeleteTable(LPCXSTR lpszQueueName);
bool DBModule_MQData_ModifyTable(LPCXSTR lpszSrcTable, LPCXSTR lpszDstTable);
bool DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* pInt_ListCount);
private:
XNETHANDLE xhDBSQL;
};
\ No newline at end of file
......@@ -286,6 +286,95 @@ bool CDBModule_MQUser::DBModule_MQUser_UserUPDate(XENGINE_PROTOCOL_USERINFO* pSt
return true;
}
/********************************************************************
函数名称:DBModule_MQUser_UserList
函数功能:获取用户列表
参数.一:pppSt_UserInfo
In/Out:Out
类型:三级指针
可空:N
意思:输出用户表信息
参数.二:pInt_ListCount
In/Out:Out
类型:整数型
可空:N
意思:输出用户表个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CDBModule_MQUser::DBModule_MQUser_UserList(XENGINE_PROTOCOL_USERINFO*** pppSt_UserInfo, int* pInt_ListCount)
{
DBModule_IsErrorOccur = false;
//查询
XNETHANDLE xhTable = 0;
__int64u nllLine = 0;
__int64u nllRow = 0;
XCHAR tszSQLStatement[256];
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
_xstprintf(tszSQLStatement, _X("SELECT * FROM `UserInfo`"));
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nllLine, &nllRow))
{
DBModule_IsErrorOccur = true;
DBModule_dwErrorCode = DataBase_GetLastError();
return false;
}
if (nllLine <= 0)
{
DBModule_IsErrorOccur = true;
DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_EMPTY;
return false;
}
*pInt_ListCount = (int)nllLine;
BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_UserInfo, (int)nllLine, sizeof(XENGINE_PROTOCOL_USERINFO));
for (__int64u i = 0; i < nllLine; i++)
{
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
if (NULL != pptszResult[1])
{
_tcsxcpy((*pppSt_UserInfo)[i]->tszUserName, pptszResult[1]);
}
if (NULL != pptszResult[2])
{
_tcsxcpy((*pppSt_UserInfo)[i]->tszUserPass, pptszResult[2]);
}
if (NULL != pptszResult[3])
{
_tcsxcpy((*pppSt_UserInfo)[i]->tszEMailAddr, pptszResult[3]);
}
if (NULL != pptszResult[4])
{
(*pppSt_UserInfo)[i]->nPhoneNumber = _ttxoll(pptszResult[4]);
}
if (NULL != pptszResult[5])
{
(*pppSt_UserInfo)[i]->nIDNumber = _ttxoll(pptszResult[5]);
}
if (NULL != pptszResult[6])
{
(*pppSt_UserInfo)[i]->nUserState = _ttxoi(pptszResult[6]);
}
if (NULL != pptszResult[7])
{
(*pppSt_UserInfo)[i]->nUserLevel = _ttxoi(pptszResult[7]);
}
if (NULL != pptszResult[8])
{
_tcsxcpy((*pppSt_UserInfo)[i]->tszLoginTime, pptszResult[8]);
}
if (NULL != pptszResult[9])
{
_tcsxcpy((*pppSt_UserInfo)[i]->tszCreateTime, pptszResult[9]);
}
}
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
return true;
}
//////////////////////////////////////////////////////////////////////////
/********************************************************************
函数名称:DBModule_MQUser_KeyInsert
......
......@@ -23,6 +23,7 @@ public:
bool DBModule_MQUser_UserQuery(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
bool DBModule_MQUser_UserDelete(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
bool DBModule_MQUser_UserUPDate(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
bool DBModule_MQUser_UserList(XENGINE_PROTOCOL_USERINFO*** pppSt_UserInfo, int* pInt_ListCount);
public:
bool DBModule_MQUser_KeyInsert(XENGINE_DBUSERKEY* pSt_UserKey);
bool DBModule_MQUser_KeyQuery(XENGINE_DBUSERKEY* pSt_UserKey);
......
......@@ -13,6 +13,7 @@ EXPORTS
DBModule_MQData_CreateTable
DBModule_MQData_DeleteTable
DBModule_MQData_ModifyTable
DBModule_MQData_ShowTable
DBModule_MQUser_Init
DBModule_MQUser_Destory
......@@ -20,6 +21,7 @@ EXPORTS
DBModule_MQUser_UserQuery
DBModule_MQUser_UserDelete
DBModule_MQUser_UserUPDate
DBModule_MQUser_UserList
DBModule_MQUser_KeyInsert
DBModule_MQUser_KeyQuery
......
......@@ -71,6 +71,10 @@ extern "C" bool DBModule_MQData_ModifyTable(LPCXSTR lpszSrcTable, LPCXSTR lpszDs
{
return m_DBData.DBModule_MQData_ModifyTable(lpszSrcTable, lpszDstTable);
}
extern "C" bool DBModule_MQData_ShowTable(XCHAR * **pppszTableName, int* pInt_ListCount)
{
return m_DBData.DBModule_MQData_ShowTable(pppszTableName, pInt_ListCount);
}
/*************************************************************************
消息用户导出函数
**************************************************************************/
......@@ -98,6 +102,10 @@ extern "C" bool DBModule_MQUser_UserUPDate(XENGINE_PROTOCOL_USERINFO * pSt_UserI
{
return m_DBUser.DBModule_MQUser_UserUPDate(pSt_UserInfo);
}
extern "C" bool DBModule_MQUser_UserList(XENGINE_PROTOCOL_USERINFO * **pppSt_UserInfo, int* pInt_ListCount)
{
return m_DBUser.DBModule_MQUser_UserList(pppSt_UserInfo, pInt_ListCount);
}
/*************************************************************************
消息绑定导出函数
**************************************************************************/
......
......@@ -7,8 +7,11 @@ EXPORTS
ProtocolModule_Packet_MQNumber
ProtocolModule_Packet_PassAuth
ProtocolModule_Packet_PassUser
ProtocolModule_Packet_Http
ProtocolModule_Packet_UserList
ProtocolModule_Packet_TopicList
ProtocolModule_Packet_UNReadCreate
ProtocolModule_Packet_UNReadInsert
ProtocolModule_Packet_UNReadDelete
ProtocolModule_Parse_Http
\ No newline at end of file
ProtocolModule_Parse_Websocket
\ No newline at end of file
......@@ -73,158 +73,11 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_Common(int nNetType, XENGINE_
}
else
{
ProtocolModule_Packet_HttpCommon(pSt_ProtocolHdr, pSt_MQProtocol, ptszMsgBuffer, pInt_MsgLen, lpszMsgBuffer, nMsgLen);
ProtocolModule_Packet_WSCommon(pSt_ProtocolHdr, pSt_MQProtocol, ptszMsgBuffer, pInt_MsgLen, lpszMsgBuffer, nMsgLen);
}
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_TCPCommon
函数功能:通用封包类
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:协议头
参数.二:pSt_MQProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:消息头
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装号的协议
参数.四:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:导出封装的协议的长度
参数.五:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:要封装的数据
参数.六:nMsgLen
In/Out:In
类型:整数型
可空:Y
意思:要封装数据的长度
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Packet::ProtocolModule_Packet_TCPCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer /* = NULL */, int nMsgLen /* = 0 */)
{
Protocol_IsErrorOccur = false;
if ((NULL == pSt_ProtocolHdr) || (NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = true;
Protocol_dwErrorCode = ERROR_MQ_MODULE_PROTOCOL_PARAMENT;
return false;
}
if (NULL == pSt_MQProtocol)
{
pSt_ProtocolHdr->unPacketSize = nMsgLen;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + nMsgLen;
}
else
{
pSt_ProtocolHdr->unPacketSize = sizeof(XENGINE_PROTOCOL_XMQ) + nMsgLen;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), pSt_MQProtocol, sizeof(XENGINE_PROTOCOL_XMQ));
if (NULL != lpszMsgBuffer)
{
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_XMQ), lpszMsgBuffer, nMsgLen);
}
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_XMQ) + nMsgLen;
}
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_HttpCommon
函数功能:HTTP通用封包类
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:协议头
参数.二:pSt_MQProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:消息头
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装号的协议
参数.四:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:导出封装的协议的长度
参数.五:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:要封装的数据
参数.六:nMsgLen
In/Out:In
类型:整数型
可空:Y
意思:要封装数据的长度
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Packet::ProtocolModule_Packet_HttpCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer /* = NULL */, int nMsgLen /* = 0 */)
{
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
Json::StreamWriterBuilder st_JsonBuilder;
st_JsonRoot["unOperatorType"] = pSt_ProtocolHdr->unOperatorType;
st_JsonRoot["unOperatorCode"] = pSt_ProtocolHdr->unOperatorCode;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)pSt_ProtocolHdr->xhToken;
st_JsonRoot["wReserve"] = pSt_ProtocolHdr->wReserve;
st_JsonRoot["byVersion"] = pSt_ProtocolHdr->byVersion;
if (NULL != pSt_MQProtocol)
{
st_JsonMQProtocol["tszMQKey"] = pSt_MQProtocol->tszMQKey;
st_JsonMQProtocol["nSerial"] = (Json::Value::Int64)pSt_MQProtocol->nSerial;
st_JsonMQProtocol["nGetTimer"] = pSt_MQProtocol->nGetTimer;
st_JsonMQProtocol["nKeepTime"] = pSt_MQProtocol->nKeepTime;
st_JsonMQProtocol["nPubTime"] = (Json::Value::Int64)pSt_MQProtocol->nPubTime;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
}
if (nMsgLen > 0)
{
st_JsonPayload["nPayType"] = (ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE)pSt_ProtocolHdr->byVersion;
st_JsonPayload["nPayLen"] = nMsgLen;
st_JsonPayload["tszPayData"] = lpszMsgBuffer;
st_JsonRoot["st_Payload"] = st_JsonPayload;
}
st_JsonBuilder["emitUTF8"] = true;
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_MQNumber
函数功能:获取序列打包函数
参数.一:pSt_ProtocolHdr
......@@ -423,6 +276,159 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_PassUser(XENGINE_PROTOCOL_USE
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_Http
函数功能:HTTP封包类
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:协议头
参数.二:pSt_MQProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:消息头
参数.三:nCode
In/Out:In
类型:整数型
可空:Y
意思:返回的状态值
参数.四:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:返回的消息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Packet::ProtocolModule_Packet_Http(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode /* = 0 */, LPCXSTR lpszMsgBuffer /* = NULL */)
{
Json::Value st_JsonRoot;
Json::StreamWriterBuilder st_JsonBuilder;
st_JsonRoot["msg"] = lpszMsgBuffer;
st_JsonRoot["code"] = nCode;
st_JsonBuilder["emitUTF8"] = true;
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_UserList
函数功能:用户信息打包
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打包的内容
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出打包大小
参数.三:pppSt_UserInfo
In/Out:In
类型:三级指针
可空:N
意思:输入要打包的数据
参数.四:nListCount
In/Out:In
类型:整数型
可空:N
意思:输入要打包的数据的个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Packet::ProtocolModule_Packet_UserList(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_PROTOCOL_USERINFO*** pppSt_UserInfo, int nListCount)
{
Protocol_IsErrorOccur = false;
Json::Value st_JsonRoot;
Json::Value st_JsonArray;
Json::StreamWriterBuilder st_JsonBuilder;
for (int i = 0; i < nListCount; i++)
{
Json::Value st_JsonObject;
st_JsonObject["tszUserName"] = (*pppSt_UserInfo)[i]->tszUserName;
st_JsonObject["tszUserPass"] = (*pppSt_UserInfo)[i]->tszUserPass;
st_JsonObject["tszEMailAddr"] = (*pppSt_UserInfo)[i]->tszEMailAddr;
st_JsonObject["nPhoneNumber"] = (Json::Value::Int64)(*pppSt_UserInfo)[i]->nPhoneNumber;
st_JsonObject["nIDNumber"] = (Json::Value::Int64)(*pppSt_UserInfo)[i]->nIDNumber;
st_JsonObject["nUserState"] = (*pppSt_UserInfo)[i]->nUserState;
st_JsonObject["nUserLevel"] = (*pppSt_UserInfo)[i]->nUserLevel;
st_JsonObject["tszLoginTime"] = (*pppSt_UserInfo)[i]->tszLoginTime;
st_JsonObject["tszCreateTime"] = (*pppSt_UserInfo)[i]->tszCreateTime;
st_JsonArray.append(st_JsonObject);
}
st_JsonRoot["code"] = 0;
st_JsonRoot["Array"] = st_JsonArray;
st_JsonRoot["Count"] = st_JsonArray.size();
st_JsonBuilder["emitUTF8"] = true;
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_TopicList
函数功能:主题列表打包
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打包的内容
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出打包大小
参数.三:pppszTableName
In/Out:In
类型:三级指针
可空:N
意思:输入要打包的数据
参数.四:nListCount
In/Out:In
类型:整数型
可空:N
意思:输入要打包的数据的个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Packet::ProtocolModule_Packet_TopicList(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** pppszTableName, int nListCount)
{
Protocol_IsErrorOccur = false;
Json::Value st_JsonRoot;
Json::Value st_JsonArray;
Json::StreamWriterBuilder st_JsonBuilder;
for (int i = 0; i < nListCount; i++)
{
Json::Value st_JsonObject;
st_JsonObject["tszTopicName"] = (*pppszTableName)[i];
st_JsonArray.append(st_JsonObject);
}
st_JsonRoot["code"] = 0;
st_JsonRoot["Array"] = st_JsonArray;
st_JsonRoot["Count"] = st_JsonArray.size();
st_JsonBuilder["emitUTF8"] = true;
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_UNReadCreate
函数功能:未读消息打包创建函数
参数.一:pSt_ProtocolHdr
......@@ -585,5 +591,172 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_UNReadDelete(XHANDLE xhToken,
delete pSt_UNRead;
pSt_UNRead = NULL;
return true;
}
///////////////////////////////////////////////////////////////////////////////
// 保护函数
///////////////////////////////////////////////////////////////////////////////
/********************************************************************
函数名称:ProtocolModule_Packet_TCPCommon
函数功能:通用封包类
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:协议头
参数.二:pSt_MQProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:消息头
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装号的协议
参数.四:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:导出封装的协议的长度
参数.五:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:要封装的数据
参数.六:nMsgLen
In/Out:In
类型:整数型
可空:Y
意思:要封装数据的长度
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Packet::ProtocolModule_Packet_TCPCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer /* = NULL */, int nMsgLen /* = 0 */)
{
Protocol_IsErrorOccur = false;
if ((NULL == pSt_ProtocolHdr) || (NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = true;
Protocol_dwErrorCode = ERROR_MQ_MODULE_PROTOCOL_PARAMENT;
return false;
}
if (NULL == pSt_MQProtocol)
{
pSt_ProtocolHdr->unPacketSize = nMsgLen;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + nMsgLen;
}
else
{
pSt_ProtocolHdr->unPacketSize = sizeof(XENGINE_PROTOCOL_XMQ) + nMsgLen;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), pSt_MQProtocol, sizeof(XENGINE_PROTOCOL_XMQ));
if (NULL != lpszMsgBuffer)
{
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_XMQ), lpszMsgBuffer, nMsgLen);
}
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + sizeof(XENGINE_PROTOCOL_XMQ) + nMsgLen;
}
return true;
}
/********************************************************************
函数名称:ProtocolModule_Packet_WSCommon
函数功能:Websocket通用封包类
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:协议头
参数.二:pSt_MQProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:消息头
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装号的协议
参数.四:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:导出封装的协议的长度
参数.五:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:要封装的数据
参数.六:nMsgLen
In/Out:In
类型:整数型
可空:Y
意思:要封装数据的长度
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Packet::ProtocolModule_Packet_WSCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer /* = NULL */, int nMsgLen /* = 0 */)
{
Json::Value st_JsonRoot;
Json::Value st_JsonMQProtocol;
Json::Value st_JsonPayload;
Json::StreamWriterBuilder st_JsonBuilder;
st_JsonRoot["unOperatorType"] = pSt_ProtocolHdr->unOperatorType;
st_JsonRoot["unOperatorCode"] = pSt_ProtocolHdr->unOperatorCode;
st_JsonRoot["xhToken"] = (Json::Value::UInt64)pSt_ProtocolHdr->xhToken;
st_JsonRoot["wReserve"] = pSt_ProtocolHdr->wReserve;
st_JsonRoot["byVersion"] = pSt_ProtocolHdr->byVersion;
if (NULL != pSt_MQProtocol)
{
st_JsonMQProtocol["tszMQKey"] = pSt_MQProtocol->tszMQKey;
st_JsonMQProtocol["nSerial"] = (Json::Value::Int64)pSt_MQProtocol->nSerial;
st_JsonMQProtocol["nGetTimer"] = pSt_MQProtocol->nGetTimer;
st_JsonMQProtocol["nKeepTime"] = pSt_MQProtocol->nKeepTime;
st_JsonMQProtocol["nPubTime"] = (Json::Value::Int64)pSt_MQProtocol->nPubTime;
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
}
if (nMsgLen > 0)
{
if (ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_BIN == pSt_ProtocolHdr->byVersion)
{
int nBLen = nMsgLen;
XCHAR* ptszBaseBuffer = (XCHAR*)malloc(XENGINE_MEMORY_SIZE_MAX);
if (NULL == ptszBaseBuffer)
{
Protocol_IsErrorOccur = true;
Protocol_dwErrorCode = ERROR_MQ_MODULE_PROTOCOL_MALLOC;
return false;
}
memset(ptszBaseBuffer, '\0', XENGINE_MEMORY_SIZE_MAX);
OPenSsl_Codec_Base64(lpszMsgBuffer, ptszBaseBuffer, &nBLen, true);
st_JsonPayload["nPayLen"] = nBLen;
st_JsonPayload["tszPayData"] = ptszBaseBuffer;
}
else
{
st_JsonPayload["nPayLen"] = nMsgLen;
st_JsonPayload["tszPayData"] = lpszMsgBuffer;
}
st_JsonRoot["st_Payload"] = st_JsonPayload;
}
st_JsonBuilder["emitUTF8"] = true;
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
return true;
}
\ No newline at end of file
......@@ -26,15 +26,18 @@ public:
~CProtocolModule_Packet();
public:
bool ProtocolModule_Packet_Common(int nNetType, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer = NULL, int nMsgLen = 0);
bool ProtocolModule_Packet_TCPCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer = NULL, int nMsgLen = 0);
bool ProtocolModule_Packet_HttpCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer = NULL, int nMsgLen = 0);
bool ProtocolModule_Packet_MQNumber(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_MQNUMBER* pSt_MQNumber, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nNetType);
bool ProtocolModule_Packet_PassAuth(XENGINE_PROTOCOL_USERAUTH* pSt_ProtocolAuth, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode);
bool ProtocolModule_Packet_PassUser(XENGINE_PROTOCOL_USERINFO* pSt_ProtocolUser, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode);
bool ProtocolModule_Packet_Http(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
bool ProtocolModule_Packet_UserList(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_PROTOCOL_USERINFO*** pppSt_UserInfo, int nListCount);
bool ProtocolModule_Packet_TopicList(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** pppszTableName, int nListCount);
public:
XHANDLE ProtocolModule_Packet_UNReadCreate(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE enPayType);
bool ProtocolModule_Packet_UNReadInsert(XHANDLE xhToken, XENGINE_DBMESSAGEQUEUE*** pppSt_DBMessage, int nListCount);
bool ProtocolModule_Packet_UNReadDelete(XHANDLE xhToken, XCHAR* ptszMsgBuffer, int* pInt_MsgLen);
protected:
bool ProtocolModule_Packet_TCPCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer = NULL, int nMsgLen = 0);
bool ProtocolModule_Packet_WSCommon(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_PROTOCOL_XMQ* pSt_MQProtocol, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszMsgBuffer = NULL, int nMsgLen = 0);
private:
};
......@@ -21,8 +21,8 @@ CProtocolModule_Parse::~CProtocolModule_Parse()
// 公有函数
///////////////////////////////////////////////////////////////////////////////
/********************************************************************
函数名称:ProtocolModule_Parse_Http
函数功能:HTTP协议解析
函数名称:ProtocolModule_Parse_Websocket
函数功能:websocket协议解析
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
......@@ -53,7 +53,7 @@ CProtocolModule_Parse::~CProtocolModule_Parse()
意思:是否成功
备注:
*********************************************************************/
bool CProtocolModule_Parse::ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XCHAR* ptszMsgBuffer, int* pInt_MsgLen)
bool CProtocolModule_Parse::ProtocolModule_Parse_Websocket(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XCHAR* ptszMsgBuffer, int* pInt_MsgLen)
{
Protocol_IsErrorOccur = false;
......@@ -97,8 +97,13 @@ bool CProtocolModule_Parse::ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int
{
pSt_ProtocolHdr->byVersion = st_JsonRoot["byVersion"].asInt();
}
if (!st_JsonRoot["byIsReply"].isNull())
{
pSt_ProtocolHdr->byIsReply = st_JsonRoot["byIsReply"].asInt();
}
}
int nPos = 0;
*pInt_MsgLen = 0;
XENGINE_PROTOCOL_XMQ st_MQProtocol;
XENGINE_PROTOCOL_USERAUTH st_ProtocolAuth;
......@@ -133,6 +138,8 @@ bool CProtocolModule_Parse::ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int
st_MQProtocol.nPubTime = st_JsonMQProtocol["nPubTime"].asInt64();
}
*pInt_MsgLen += sizeof(XENGINE_PROTOCOL_XMQ);
memcpy(ptszMsgBuffer + nPos, &st_MQProtocol, sizeof(XENGINE_PROTOCOL_XMQ));
nPos += sizeof(XENGINE_PROTOCOL_XMQ);
}
//后者负载的是验证协议
if (!st_JsonRoot["st_Auth"].isNull())
......@@ -150,6 +157,8 @@ bool CProtocolModule_Parse::ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int
st_ProtocolAuth.enDeviceType = (ENUM_PROTOCOLDEVICE_TYPE)st_JsonAuth["enDeviceType"].asInt();
}
*pInt_MsgLen += sizeof(XENGINE_PROTOCOL_USERAUTH);
memcpy(ptszMsgBuffer + nPos, &st_ProtocolAuth, sizeof(XENGINE_PROTOCOL_USERAUTH));
nPos += sizeof(XENGINE_PROTOCOL_USERAUTH);
}
if (!st_JsonRoot["st_User"].isNull())
{
......@@ -184,34 +193,25 @@ bool CProtocolModule_Parse::ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int
_tcsxcpy(st_ProtocolInfo.tszEMailAddr, st_JsonUser["tszEMailAddr"].asCString());
}
*pInt_MsgLen += sizeof(XENGINE_PROTOCOL_USERINFO);
}
//或者包含附加内容
if (!st_JsonRoot["st_Payload"].isNull())
{
Json::Value st_JsonPayLoad = st_JsonRoot["st_Payload"];
*pInt_MsgLen += st_JsonPayLoad["nPayLen"].asInt();
}
int nPos = 0;
if (!st_JsonRoot["st_MQProtocol"].isNull())
{
memcpy(ptszMsgBuffer + nPos, &st_MQProtocol, sizeof(XENGINE_PROTOCOL_XMQ));
nPos += sizeof(XENGINE_PROTOCOL_XMQ);
}
if (!st_JsonRoot["st_Auth"].isNull())
{
memcpy(ptszMsgBuffer + nPos, &st_ProtocolAuth, sizeof(XENGINE_PROTOCOL_USERAUTH));
nPos += sizeof(XENGINE_PROTOCOL_USERAUTH);
}
if (!st_JsonRoot["st_User"].isNull())
{
memcpy(ptszMsgBuffer + nPos, &st_ProtocolInfo, sizeof(XENGINE_PROTOCOL_USERINFO));
nPos += sizeof(XENGINE_PROTOCOL_USERINFO);
}
//或者包含附加内容
if (!st_JsonRoot["st_Payload"].isNull())
{
Json::Value st_JsonPayLoad = st_JsonRoot["st_Payload"];
memcpy(ptszMsgBuffer + nPos, st_JsonPayLoad["tszPayData"].asCString(), st_JsonPayLoad["nPayLen"].asInt());
if (ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_BIN == pSt_ProtocolHdr->byVersion)
{
int nBLen = st_JsonPayLoad["nPayLen"].asInt();
OPenSsl_Codec_Base64(st_JsonPayLoad["tszPayData"].asCString(), ptszMsgBuffer + nPos, &nBLen, false);
*pInt_MsgLen += nBLen;
}
else
{
memcpy(ptszMsgBuffer + nPos, st_JsonPayLoad["tszPayData"].asCString(), st_JsonPayLoad["nPayLen"].asInt());
*pInt_MsgLen += st_JsonPayLoad["nPayLen"].asInt();
}
}
return true;
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ public:
CProtocolModule_Parse();
~CProtocolModule_Parse();
public:
bool ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XCHAR* ptszMsgBuffer, int* pInt_MsgLen);
bool ProtocolModule_Parse_Websocket(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XCHAR* ptszMsgBuffer, int* pInt_MsgLen);
protected:
private:
};
......@@ -154,6 +154,93 @@ extern "C" bool ProtocolModule_Packet_PassAuth(XENGINE_PROTOCOL_USERAUTH* pSt_Pr
*********************************************************************/
extern "C" bool ProtocolModule_Packet_PassUser(XENGINE_PROTOCOL_USERINFO* pSt_ProtocolUser, XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode);
/********************************************************************
函数名称:ProtocolModule_Packet_Http
函数功能:HTTP封包类
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:协议头
参数.二:pSt_MQProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:消息头
参数.三:nCode
In/Out:In
类型:整数型
可空:Y
意思:返回的状态值
参数.四:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:返回的消息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool ProtocolModule_Packet_Http(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
/********************************************************************
函数名称:ProtocolModule_Packet_UserList
函数功能:用户信息打包
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打包的内容
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出打包大小
参数.三:pppSt_UserInfo
In/Out:In
类型:三级指针
可空:N
意思:输入要打包的数据
参数.四:nListCount
In/Out:In
类型:整数型
可空:N
意思:输入要打包的数据的个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool ProtocolModule_Packet_UserList(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_PROTOCOL_USERINFO*** pppSt_UserInfo, int nListCount);
/********************************************************************
函数名称:ProtocolModule_Packet_TopicList
函数功能:主题列表打包
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打包的内容
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出打包大小
参数.三:pppszTableName
In/Out:In
类型:三级指针
可空:N
意思:输入要打包的数据
参数.四:nListCount
In/Out:In
类型:整数型
可空:N
意思:输入要打包的数据的个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool ProtocolModule_Packet_TopicList(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** pppszTableName, int nListCount);
/********************************************************************
函数名称:ProtocolModule_Packet_UNReadCreate
函数功能:未读消息打包创建函数
参数.一:pSt_ProtocolHdr
......@@ -224,8 +311,8 @@ extern "C" bool ProtocolModule_Packet_UNReadDelete(XHANDLE xhToken, XCHAR* ptszM
/* 解析类函数 */
/************************************************************************/
/********************************************************************
函数名称:ProtocolModule_Parse_Http
函数功能:HTTP协议解析
函数名称:ProtocolModule_Parse_Websocket
函数功能:websocket协议解析
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
......@@ -256,4 +343,4 @@ extern "C" bool ProtocolModule_Packet_UNReadDelete(XHANDLE xhToken, XCHAR* ptszM
意思:是否成功
备注:
*********************************************************************/
extern "C" bool ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR * pSt_ProtocolHdr = NULL, XCHAR *ptszMsgBuffer = NULL, int* pInt_MsgLen = NULL);
\ No newline at end of file
extern "C" bool ProtocolModule_Parse_Websocket(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR * pSt_ProtocolHdr = NULL, XCHAR *ptszMsgBuffer = NULL, int* pInt_MsgLen = NULL);
\ No newline at end of file
......@@ -47,6 +47,18 @@ extern "C" bool ProtocolModule_Packet_PassUser(XENGINE_PROTOCOL_USERINFO * pSt_P
{
return m_ProtocolPacket.ProtocolModule_Packet_PassUser(pSt_ProtocolUser, ptszMsgBuffer, pInt_MsgLen, nCode);
}
extern "C" bool ProtocolModule_Packet_Http(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, int nCode, LPCXSTR lpszMsgBuffer)
{
return m_ProtocolPacket.ProtocolModule_Packet_Http(ptszMsgBuffer, pInt_MsgLen, nCode, lpszMsgBuffer);
}
extern "C" bool ProtocolModule_Packet_UserList(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XENGINE_PROTOCOL_USERINFO * **pppSt_UserInfo, int nListCount)
{
return m_ProtocolPacket.ProtocolModule_Packet_UserList(ptszMsgBuffer, pInt_MsgLen, pppSt_UserInfo, nListCount);
}
extern "C" bool ProtocolModule_Packet_TopicList(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XCHAR * **pppszTableName, int nListCount)
{
return m_ProtocolPacket.ProtocolModule_Packet_TopicList(ptszMsgBuffer, pInt_MsgLen, pppszTableName, nListCount);
}
extern "C" XHANDLE ProtocolModule_Packet_UNReadCreate(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE enPayType)
{
return m_ProtocolPacket.ProtocolModule_Packet_UNReadCreate(pSt_ProtocolHdr, enPayType);
......@@ -62,7 +74,7 @@ extern "C" bool ProtocolModule_Packet_UNReadDelete(XHANDLE xhToken, XCHAR * ptsz
/************************************************************************/
/* 解析类函数 */
/************************************************************************/
extern "C" bool ProtocolModule_Parse_Http(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XCHAR *ptszMsgBuffer, int* pInt_MsgLen)
extern "C" bool ProtocolModule_Parse_Websocket(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XCHAR *ptszMsgBuffer, int* pInt_MsgLen)
{
return m_ProtocolParse.ProtocolModule_Parse_Http(lpszMsgBuffer, nMsgLen, pSt_ProtocolHdr, ptszMsgBuffer, pInt_MsgLen);
return m_ProtocolParse.ProtocolModule_Parse_Websocket(lpszMsgBuffer, nMsgLen, pSt_ProtocolHdr, ptszMsgBuffer, pInt_MsgLen);
}
\ No newline at end of file
......@@ -21,6 +21,8 @@
#include <XEngine_Include/XEngine_ProtocolHdr.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
#include <XEngine_Include/XEngine_Core/OPenSsl_Define.h>
#include <XEngine_Include/XEngine_Core/OPenSsl_Error.h>
#include <XEngine_Include/XEngine_HelpComponents/DataBase_Define.h>
#include "../XQueue_ProtocolHdr.h"
#include "../MQCore_DBModule/DBModule_Define.h"
......@@ -43,6 +45,7 @@ extern XLONG Protocol_dwErrorCode;
#ifdef _MSC_BUILD
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
#pragma comment(lib,"XEngine_Core/XEngine_OPenSsl")
#ifdef _DEBUG
#ifdef _WIN64
#pragma comment(lib,"../x64/Debug/jsoncpp")
......
......@@ -7,7 +7,8 @@ EXPORTS
SessionModule_Client_Destory
SessionModule_Client_Create
SessionModule_Client_Delete
SessionModule_Client_DeleteByUser
SessionModule_Client_GetUser
SessionModule_Client_GetAddr
SessionModule_Client_GetType
SessionModule_Client_Heart
\ No newline at end of file
SessionModule_Client_GetInfoByUser
SessionModule_Client_GetType
\ No newline at end of file
......@@ -13,8 +13,6 @@
*********************************************************************/
CSessionModule_Client::CSessionModule_Client()
{
bRun = false;
pSTDThread = NULL;
}
CSessionModule_Client::~CSessionModule_Client()
{
......@@ -25,34 +23,15 @@ CSessionModule_Client::~CSessionModule_Client()
/********************************************************************
函数名称:SessionModule_Client_Init
函数功能:初始化客户端会话管理器
参数.一:nSessionTime
In/Out:In
类型:整数型
可空:N
意思:输入会话超时时间,单位秒
参数.二:fpCall_Timeout
In/Out:In/Out
类型:回调函数
可空:N
意思:设置会话超时回调
参数.三:lParam
In/Out:In/Out
类型:无类型指针
可空:Y
意思:回调函数自定义参数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CSessionModule_Client::SessionModule_Client_Init(int nSessionTime, CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT fpCall_Timeout, XPVOID lParam /* = NULL */)
bool CSessionModule_Client::SessionModule_Client_Init()
{
Session_IsErrorOccur = false;
bRun = true;
m_lParam = lParam;
lpCall_Timeout = fpCall_Timeout;
pSTDThread = make_shared<thread>();
return true;
}
/************************************************************************
......@@ -67,12 +46,9 @@ bool CSessionModule_Client::SessionModule_Client_Destory()
{
Session_IsErrorOccur = false;
bRun = false;
if (pSTDThread->joinable())
{
pSTDThread->join();
}
st_Locker.lock();
stl_MapSession.clear();
st_Locker.unlock();
return true;
}
/********************************************************************
......@@ -83,11 +59,11 @@ bool CSessionModule_Client::SessionModule_Client_Destory()
类型:常量字符指针
可空:N
意思:输入客户端地址
参数.二:lpszUserName
参数.二:pSt_UserInfo
In/Out:In
类型:常量字符指针
类型:数据结构指针
可空:N
意思:输入用户
意思:输入用户信息
参数.三:nNetType
In/Out:In
类型:整数型
......@@ -98,7 +74,7 @@ bool CSessionModule_Client::SessionModule_Client_Destory()
意思:是否成功
备注:
*********************************************************************/
bool CSessionModule_Client::SessionModule_Client_Create(LPCXSTR lpszClientAddr, LPCXSTR lpszUserName, int nNetType)
bool CSessionModule_Client::SessionModule_Client_Create(LPCXSTR lpszClientAddr, XENGINE_PROTOCOL_USERINFO *pSt_UserInfo, int nNetType)
{
Session_IsErrorOccur = false;
......@@ -113,7 +89,7 @@ bool CSessionModule_Client::SessionModule_Client_Create(LPCXSTR lpszClientAddr,
st_SessionInfo.nNetType = nNetType;
st_SessionInfo.nTimeStart = time(NULL);
_tcsxcpy(st_SessionInfo.tszUserName, lpszUserName);
st_SessionInfo.st_UserInfo = *pSt_UserInfo;
_tcsxcpy(st_SessionInfo.tszUserAddr, lpszClientAddr);
st_Locker.lock();
......@@ -148,6 +124,36 @@ bool CSessionModule_Client::SessionModule_Client_Delete(LPCXSTR lpszClientAddr)
return true;
}
/********************************************************************
函数名称:SessionModule_Client_DeleteByUser
函数功能:通过同户名删除会话
参数.一:lpszClientUser
In/Out:In
类型:常量字符指针
可空:N
意思:输入要操作的客户端
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CSessionModule_Client::SessionModule_Client_DeleteByUser(LPCXSTR lpszClientUser)
{
Session_IsErrorOccur = false;
st_Locker.lock();
for (auto stl_MapIterator = stl_MapSession.begin(); stl_MapIterator != stl_MapSession.end(); stl_MapIterator++)
{
if (0 == _tcsxnicmp(lpszClientUser, stl_MapIterator->second.st_UserInfo.tszUserName, _tcsxlen(lpszClientUser)))
{
stl_MapSession.erase(stl_MapIterator);
break;
}
}
st_Locker.unlock();
return true;
}
/************************************************************************
函数名称:SessionModule_Client_GetUser
函数功能:通过会话ID获取用户
......@@ -187,7 +193,7 @@ bool CSessionModule_Client::SessionModule_Client_GetUser(LPCXSTR lpszSessionStr,
}
if (NULL != ptszUserName)
{
_tcsxcpy(ptszUserName, stl_MapIterator->second.tszUserName);
_tcsxcpy(ptszUserName, stl_MapIterator->second.st_UserInfo.tszUserName);
}
st_Locker.unlock_shared();
return true;
......@@ -203,14 +209,14 @@ bool CSessionModule_Client::SessionModule_Client_GetUser(LPCXSTR lpszSessionStr,
参数.二:ptszUserAddr
In/Out:Out
类型:字符指针
可空:N
可空:Y
意思:输出用户地址
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CSessionModule_Client::SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR* ptszUserAddr)
bool CSessionModule_Client::SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR* ptszUserAddr /* = NULL */)
{
Session_IsErrorOccur = false;
......@@ -224,10 +230,13 @@ bool CSessionModule_Client::SessionModule_Client_GetAddr(LPCXSTR lpszUserName, X
st_Locker.lock_shared();
for (auto stl_MapIterator = stl_MapSession.begin(); stl_MapIterator != stl_MapSession.end(); stl_MapIterator++)
{
if (0 == _tcsxncmp(lpszUserName, stl_MapIterator->second.tszUserName, _tcsxlen(lpszUserName)))
if (0 == _tcsxncmp(lpszUserName, stl_MapIterator->second.st_UserInfo.tszUserName, _tcsxlen(lpszUserName)))
{
bFound = true;
_tcsxcpy(ptszUserAddr, stl_MapIterator->second.tszUserAddr);
if (NULL != ptszUserAddr)
{
_tcsxcpy(ptszUserAddr, stl_MapIterator->second.tszUserAddr);
}
break;
}
}
......@@ -242,71 +251,84 @@ bool CSessionModule_Client::SessionModule_Client_GetAddr(LPCXSTR lpszUserName, X
return true;
}
/********************************************************************
函数名称:SessionModule_Client_GetType
函数功能:通过客户端获得连接的网络类型
参数.一:lpszSessionStr
函数名称:SessionModule_Client_GetInfoByUser
函数功能:通过用户名获取用户信息
参数.一:lpszUserName
In/Out:In
类型:常量字符指针
可空:N
意思:输入要操作的客户端
参数.二:pInt_NetType
意思:输入用户名
参数.二:pSt_UserInfo
In/Out:Out
类型:整数型指针
类型:数据结构指针
可空:N
意思:输出网络类型
意思:输出用户信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CSessionModule_Client::SessionModule_Client_GetType(LPCXSTR lpszSessionStr, int* pInt_NetType)
bool CSessionModule_Client::SessionModule_Client_GetInfoByUser(LPCXSTR lpszUserName, XENGINE_PROTOCOL_USERINFO* pSt_UserInfo)
{
Session_IsErrorOccur = false;
if (NULL == lpszSessionStr)
if (NULL == lpszUserName)
{
Session_IsErrorOccur = true;
Session_dwErrorCode = ERROR_MQ_MODULE_SESSION_PARAMENT;
return false;
}
bool bFound = false;
st_Locker.lock_shared();
unordered_map<tstring, XENGINE_SESSIONINFO>::iterator stl_MapIterator = stl_MapSession.find(lpszSessionStr);
if (stl_MapIterator == stl_MapSession.end())
for (auto stl_MapIterator = stl_MapSession.begin(); stl_MapIterator != stl_MapSession.end(); stl_MapIterator++)
{
if (0 == _tcsxncmp(lpszUserName, stl_MapIterator->second.st_UserInfo.tszUserName, _tcsxlen(lpszUserName)))
{
bFound = true;
*pSt_UserInfo = stl_MapIterator->second.st_UserInfo;
break;
}
}
st_Locker.unlock_shared();
if (!bFound)
{
Session_IsErrorOccur = true;
Session_dwErrorCode = ERROR_MQ_MODULE_SESSION_NOTFOUND;
st_Locker.unlock_shared();
return false;
}
*pInt_NetType = stl_MapIterator->second.nNetType;
st_Locker.unlock_shared();
return true;
}
/********************************************************************
函数名称:SessionModule_Client_Heart
函数功能:触发一次心跳
参数.一:lpszClientAddr
函数名称:SessionModule_Client_GetType
函数功能:通过客户端获得连接的网络类型
参数.一:lpszSessionStr
In/Out:In
类型:常量字符指针
可空:N
意思:输入要触发的客户端
意思:输入要操作的客户端
参数.二:pInt_NetType
In/Out:Out
类型:整数型指针
可空:N
意思:输出网络类型
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool CSessionModule_Client::SessionModule_Client_Heart(LPCXSTR lpszClientAddr)
bool CSessionModule_Client::SessionModule_Client_GetType(LPCXSTR lpszSessionStr, int* pInt_NetType)
{
Session_IsErrorOccur = false;
if (NULL == lpszClientAddr)
if (NULL == lpszSessionStr)
{
Session_IsErrorOccur = true;
Session_dwErrorCode = ERROR_MQ_MODULE_SESSION_PARAMENT;
return false;
}
st_Locker.lock_shared();
unordered_map<tstring, XENGINE_SESSIONINFO>::iterator stl_MapIterator = stl_MapSession.find(lpszClientAddr);
unordered_map<tstring, XENGINE_SESSIONINFO>::iterator stl_MapIterator = stl_MapSession.find(lpszSessionStr);
if (stl_MapIterator == stl_MapSession.end())
{
Session_IsErrorOccur = true;
......@@ -314,42 +336,7 @@ bool CSessionModule_Client::SessionModule_Client_Heart(LPCXSTR lpszClientAddr)
st_Locker.unlock_shared();
return false;
}
stl_MapIterator->second.nTimeStart = time(NULL);
*pInt_NetType = stl_MapIterator->second.nNetType;
st_Locker.unlock_shared();
return true;
}
///////////////////////////////////////////////////////////////////////////////
// 线程函数
///////////////////////////////////////////////////////////////////////////////
XHTHREAD CALLBACK CSessionModule_Client::SessionModule_Client_Thread(XPVOID lParam)
{
CSessionModule_Client* pClass_This = (CSessionModule_Client*)lParam;
list<XENGINE_SESSIONINFO> stl_ListClient;
while (pClass_This->bRun)
{
pClass_This->st_Locker.lock_shared();
unordered_map<tstring, XENGINE_SESSIONINFO>::const_iterator stl_MapIterator = pClass_This->stl_MapSession.begin();
for (; stl_MapIterator != pClass_This->stl_MapSession.end(); stl_MapIterator++)
{
time_t nTimeEnd = time(NULL);
if ((nTimeEnd - stl_MapIterator->second.nTimeStart) > pClass_This->nSessionTime)
{
//移除客户端
stl_ListClient.push_back(stl_MapIterator->second);
break;
}
}
pClass_This->st_Locker.unlock_shared();
//是否有需要移除的客户端
if (!stl_ListClient.empty())
{
for (auto stl_ListIterator = stl_ListClient.begin(); stl_ListIterator != stl_ListClient.end(); stl_ListIterator++)
{
pClass_This->lpCall_Timeout(stl_ListIterator->tszUserAddr, stl_ListIterator->tszUserName, (ENUM_MQCORE_SESSION_CLIENT_TYPE)stl_ListIterator->nNetType, pClass_This->m_lParam);
}
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}
return 0;
}
\ No newline at end of file
......@@ -12,8 +12,8 @@
*********************************************************************/
typedef struct
{
XENGINE_PROTOCOL_USERINFO st_UserInfo; //用户登录信息
XCHAR tszUserAddr[128]; //用户地址
XCHAR tszUserName[128]; //登录的用户名
time_t nTimeStart; //时间
int nNetType; //网络类型
}XENGINE_SESSIONINFO, * LPXENGINE_SESSIONINFO;
......@@ -24,25 +24,17 @@ public:
CSessionModule_Client();
~CSessionModule_Client();
public:
bool SessionModule_Client_Init(int nSessionTime, CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT fpCall_Timeout, XPVOID lParam = NULL);
bool SessionModule_Client_Init();
bool SessionModule_Client_Destory();
bool SessionModule_Client_Create(LPCXSTR lpszClientAddr, LPCXSTR lpszUserName, int nNetType);
bool SessionModule_Client_Create(LPCXSTR lpszClientAddr, XENGINE_PROTOCOL_USERINFO *pSt_UserInfo, int nNetType);
bool SessionModule_Client_Delete(LPCXSTR lpszClientAddr);
bool SessionModule_Client_DeleteByUser(LPCXSTR lpszClientUser);
bool SessionModule_Client_GetUser(LPCXSTR lpszSessionStr, XCHAR* ptszUserName = NULL);
bool SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR* ptszUserAddr);
bool SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR* ptszUserAddr = NULL);
bool SessionModule_Client_GetInfoByUser(LPCXSTR lpszUserName, XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
bool SessionModule_Client_GetType(LPCXSTR lpszSessionStr, int* pInt_NetType);
bool SessionModule_Client_Heart(LPCXSTR lpszClientAddr);
protected:
static XHTHREAD CALLBACK SessionModule_Client_Thread(XPVOID lParam);
private:
bool bRun;
int nSessionTime;
private:
XPVOID m_lParam;
CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT lpCall_Timeout;
private:
shared_mutex st_Locker;
shared_ptr<thread> pSTDThread;
private:
unordered_map<tstring, XENGINE_SESSIONINFO> stl_MapSession;
};
......@@ -21,10 +21,6 @@ typedef enum
ENUM_MQCORE_SESSION_CLIENT_TYPE_HTTP = 3
}ENUM_MQCORE_SESSION_CLIENT_TYPE;
//////////////////////////////////////////////////////////////////////////
// 导出回调函数
//////////////////////////////////////////////////////////////////////////
typedef void(CALLBACK* CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT)(LPCXSTR lpszClientAddr, LPCXSTR lpszClientUser, ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType, XPVOID lParam);
//////////////////////////////////////////////////////////////////////////
// 导出函数
//////////////////////////////////////////////////////////////////////////
extern "C" XLONG SessionModule_GetLastError(int* pInt_SysError = NULL);
......@@ -34,27 +30,12 @@ extern "C" XLONG SessionModule_GetLastError(int* pInt_SysError = NULL);
/********************************************************************
函数名称:SessionModule_Client_Init
函数功能:初始化客户端会话管理器
参数.一:nSessionTime
In/Out:In
类型:整数型
可空:N
意思:输入会话超时时间,单位秒
参数.二:fpCall_Timeout
In/Out:In/Out
类型:回调函数
可空:N
意思:设置会话超时回调
参数.三:lParam
In/Out:In/Out
类型:无类型指针
可空:Y
意思:回调函数自定义参数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool SessionModule_Client_Init(int nSessionTime, CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT fpCall_Timeout, XPVOID lParam = NULL);
extern "C" bool SessionModule_Client_Init();
/************************************************************************
函数名称:SessionModule_Client_Destory
函数功能:销毁会话管理器
......@@ -72,11 +53,11 @@ extern "C" bool SessionModule_Client_Destory();
类型:常量字符指针
可空:N
意思:输入客户端地址
参数.二:lpszUserName
参数.二:pSt_UserInfo
In/Out:In
类型:常量字符指针
类型:数据结构指针
可空:N
意思:输入用户
意思:输入用户信息
参数.三:nNetType
In/Out:In
类型:整数型
......@@ -87,7 +68,7 @@ extern "C" bool SessionModule_Client_Destory();
意思:是否成功
备注:
*********************************************************************/
extern "C" bool SessionModule_Client_Create(LPCXSTR lpszClientAddr, LPCXSTR lpszUserName, int nNetType);
extern "C" bool SessionModule_Client_Create(LPCXSTR lpszClientAddr, XENGINE_PROTOCOL_USERINFO * pSt_UserInfo, int nNetType);
/********************************************************************
函数名称:SessionModule_Client_Delete
函数功能:删除一个用户
......@@ -102,6 +83,20 @@ extern "C" bool SessionModule_Client_Create(LPCXSTR lpszClientAddr, LPCXSTR lpsz
备注:
*********************************************************************/
extern "C" bool SessionModule_Client_Delete(LPCXSTR lpszClientAddr);
/********************************************************************
函数名称:SessionModule_Client_DeleteByUser
函数功能:通过同户名删除会话
参数.一:lpszClientUser
In/Out:In
类型:常量字符指针
可空:N
意思:输入要操作的客户端
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool SessionModule_Client_DeleteByUser(LPCXSTR lpszClientUser);
/************************************************************************
函数名称:SessionModule_Client_GetUser
函数功能:通过会话ID获取用户
......@@ -132,44 +127,49 @@ extern "C" bool SessionModule_Client_GetUser(LPCXSTR lpszSessionStr, XCHAR* ptsz
参数.二:ptszUserAddr
In/Out:Out
类型:字符指针
可空:N
可空:Y
意思:输出用户地址
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR* ptszUserAddr);
extern "C" bool SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR* ptszUserAddr = NULL);
/********************************************************************
函数名称:SessionModule_Client_GetType
函数功能:通过客户端获得连接的网络类型
参数.一:lpszSessionStr
函数名称:SessionModule_Client_GetInfoByUser
函数功能:通过用户名获取用户信息
参数.一:lpszUserName
In/Out:In
类型:常量字符指针
可空:N
意思:输入要操作的客户端
参数.二:pInt_NetType
意思:输入用户名
参数.二:pSt_UserInfo
In/Out:Out
类型:整数型指针
类型:数据结构指针
可空:N
意思:输出网络类型
意思:输出用户信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool SessionModule_Client_GetType(LPCXSTR lpszSessionStr, int* pInt_NetType);
extern "C" bool SessionModule_Client_GetInfoByUser(LPCXSTR lpszUserName, XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
/********************************************************************
函数名称:SessionModule_Client_Heart
函数功能:触发一次心跳
参数.一:lpszClientAddr
函数名称:SessionModule_Client_GetType
函数功能:通过客户端获得连接的网络类型
参数.一:lpszSessionStr
In/Out:In
类型:常量字符指针
可空:N
意思:输入要触发的客户端
意思:输入要操作的客户端
参数.二:pInt_NetType
In/Out:Out
类型:整数型指针
可空:N
意思:输出网络类型
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" bool SessionModule_Client_Heart(LPCXSTR lpszClientAddr);
\ No newline at end of file
extern "C" bool SessionModule_Client_GetType(LPCXSTR lpszSessionStr, int* pInt_NetType);
\ No newline at end of file
......@@ -29,22 +29,26 @@ extern "C" XLONG SessionModule_GetLastError(int* pInt_SysError)
/************************************************************************/
/* 客户端会话 */
/************************************************************************/
extern "C" bool SessionModule_Client_Init(int nSessionTime, CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT fpCall_Timeout, XPVOID lParam)
extern "C" bool SessionModule_Client_Init()
{
return m_SessionClient.SessionModule_Client_Init(nSessionTime, fpCall_Timeout, lParam);
return m_SessionClient.SessionModule_Client_Init();
}
extern "C" bool SessionModule_Client_Destory()
{
return m_SessionClient.SessionModule_Client_Destory();
}
extern "C" bool SessionModule_Client_Create(LPCXSTR lpszClientAddr, LPCXSTR lpszUserName, int nNetType)
extern "C" bool SessionModule_Client_Create(LPCXSTR lpszClientAddr, XENGINE_PROTOCOL_USERINFO * pSt_UserInfo, int nNetType)
{
return m_SessionClient.SessionModule_Client_Create(lpszClientAddr, lpszUserName, nNetType);
return m_SessionClient.SessionModule_Client_Create(lpszClientAddr, pSt_UserInfo, nNetType);
}
extern "C" bool SessionModule_Client_Delete(LPCXSTR lpszClientAddr)
{
return m_SessionClient.SessionModule_Client_Delete(lpszClientAddr);
}
extern "C" bool SessionModule_Client_DeleteByUser(LPCXSTR lpszClientUser)
{
return m_SessionClient.SessionModule_Client_DeleteByUser(lpszClientUser);
}
extern "C" bool SessionModule_Client_GetUser(LPCXSTR lpszSessionStr, XCHAR * ptszUserName)
{
return m_SessionClient.SessionModule_Client_GetUser(lpszSessionStr, ptszUserName);
......@@ -53,11 +57,11 @@ extern "C" bool SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR * ptszU
{
return m_SessionClient.SessionModule_Client_GetAddr(lpszUserName, ptszUserAddr);
}
extern "C" bool SessionModule_Client_GetType(LPCXSTR lpszSessionStr, int* pInt_NetType)
extern "C" bool SessionModule_Client_GetInfoByUser(LPCXSTR lpszUserName, XENGINE_PROTOCOL_USERINFO * pSt_UserInfo)
{
return m_SessionClient.SessionModule_Client_GetType(lpszSessionStr, pInt_NetType);
return m_SessionClient.SessionModule_Client_GetInfoByUser(lpszUserName, pSt_UserInfo);
}
extern "C" bool SessionModule_Client_Heart(LPCXSTR lpszClientAddr)
extern "C" bool SessionModule_Client_GetType(LPCXSTR lpszSessionStr, int* pInt_NetType)
{
return m_SessionClient.SessionModule_Client_Heart(lpszClientAddr);
return m_SessionClient.SessionModule_Client_GetType(lpszSessionStr, pInt_NetType);
}
\ No newline at end of file
......@@ -21,17 +21,17 @@
#include <shared_mutex>
#include <unordered_map>
#include <XEngine_Include/XEngine_CommHdr.h>
#include <XEngine_Include/XEngine_ProtocolHdr.h>
#include <XEngine_Include/XEngine_Types.h>
#include "../XQueue_ProtocolHdr.h"
#include "Session_Define.h"
#include "Session_Error.h"
using namespace std;
#ifdef _UNICODE
typedef std::wstring tstring;
#else
typedef std::string tstring;
#endif
#include "../XQueue_ProtocolHdr.h"
#include "Session_Define.h"
#include "Session_Error.h"
/********************************************************************
// Created: 2021/07/02 10:16:47
// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_SessionModule\pch.h
......
......@@ -11,7 +11,7 @@ XHTHREAD CALLBACK MessageQueue_HttpThread(XPVOID lParam)
continue;
}
int nListCount = 0;
RFCCOMPONENTS_HTTP_PKTCLIENT** ppSst_ListAddr;
XENGINE_MANAGEPOOL_TASKEVENT** ppSst_ListAddr;
HttpProtocol_Server_GetPoolEx(xhHTTPPacket, nThreadPos, &ppSst_ListAddr, &nListCount);
for (int i = 0; i < nListCount; i++)
......@@ -40,64 +40,66 @@ XHTHREAD CALLBACK MessageQueue_HttpThread(XPVOID lParam)
}
bool MessageQueue_Http_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR** pptszListHdr, int nHdrCount)
{
int nPKTLen = 4096;
XCHAR tszPKTBuffer[4096];
XCHAR tszKey[MAX_PATH];
XCHAR tszValue[MAX_PATH];
memset(tszKey, '\0', MAX_PATH);
memset(tszValue, '\0', MAX_PATH);
memset(tszPKTBuffer, '\0', sizeof(tszPKTBuffer));
LPCXSTR lpszPostMethod = _X("POST");
LPCXSTR lpszGetMethod = _X("GET");
LPCXSTR lpszAPIGet = _X("get");
LPCXSTR lpszAPIUser = _X("user");
LPCXSTR lpszAPITopic = _X("topic");
if (0 == _tcsxnicmp(lpszPostMethod, pSt_HTTPParam->tszHttpMethod, _tcsxlen(lpszPostMethod)))
{
int nPLen = 0;
XCHAR tszMsgBuffer[4096];
XENGINE_PROTOCOLHDR st_ProtocolHdr;
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
ProtocolModule_Parse_Http(lpszMsgBuffer, nMsgLen, &st_ProtocolHdr, tszMsgBuffer, &nPLen);
MessageQueue_TCP_Handle(&st_ProtocolHdr, lpszClientAddr, tszMsgBuffer, nPLen, XENGINE_MQAPP_NETTYPE_HTTP);
}
else if (0 == _tcsxnicmp(lpszGetMethod, pSt_HTTPParam->tszHttpMethod, _tcsxlen(lpszGetMethod)))
{
//http://127.0.0.1:5201/api?function=get&token=112&key=xengine&serial=1
HttpProtocol_ServerHelp_GetParament(pSt_HTTPParam->tszHttpUri, &pptszListHdr, &nHdrCount);
if (4 != nHdrCount)
int nUrlCount = 0;
XCHAR** ppSt_ListUrl;
HttpProtocol_ServerHelp_GetParament(pSt_HTTPParam->tszHttpUri, &ppSt_ListUrl, &nUrlCount);
if (nUrlCount < 1)
{
int nPKTLen = 8196;
XCHAR tszPKTBuffer[8196];
RFCCOMPONENTS_HTTP_HDRPARAM st_HTTPHdr;
memset(tszPKTBuffer, '\0', sizeof(tszPKTBuffer));
memset(&st_HTTPHdr, '\0', sizeof(RFCCOMPONENTS_HTTP_HDRPARAM));
st_HTTPHdr.nHttpCode = 400;
st_HTTPHdr.bIsClose = true;
HttpProtocol_Server_SendMsgEx(xhHTTPPacket, tszPKTBuffer, &nPKTLen, &st_HTTPHdr);
NetCore_TCPXCore_SendEx(xhHTTPSocket, lpszClientAddr, tszPKTBuffer, nPKTLen);
ProtocolModule_Packet_Http(tszPKTBuffer, &nPKTLen, 400, "url parament is incorrent");
XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP);
return false;
}
XCHAR tszKey[128];
XCHAR tszValue[128];
XENGINE_PROTOCOLHDR st_ProtocolHdr;
XENGINE_PROTOCOL_XMQ st_MQProtocol;
memset(tszKey, '\0', sizeof(tszKey));
memset(tszValue, '\0', sizeof(tszValue));
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
memset(&st_MQProtocol, '\0', sizeof(XENGINE_PROTOCOL_XMQ));
BaseLib_OperatorString_GetKeyValue(pptszListHdr[1], "=", tszKey, tszValue);
st_ProtocolHdr.xhToken = _ttxoll(tszValue);
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQGET;
st_ProtocolHdr.xhToken = sizeof(XENGINE_PROTOCOL_XMQ);
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
//获取函数
BaseLib_OperatorString_GetKeyValue(ppSt_ListUrl[0], _X("="), tszKey, tszValue);
if (0 == _tcsxnicmp(lpszAPIGet, tszValue, _tcsxlen(lpszAPIGet)))
{
memset(tszValue, '\0', MAX_PATH);
BaseLib_OperatorString_GetKeyValue(ppSt_ListUrl[1], _X("="), tszKey, tszValue);
if (0 == _tcsxnicmp(lpszAPIUser, tszValue, _tcsxlen(lpszAPIUser)))
{
//用户 http://127.0.0.1:5202/api?function=get&method=user
int nListCount = 0;
XENGINE_PROTOCOL_USERINFO** ppSt_UserInfo;
DBModule_MQUser_UserList(&ppSt_UserInfo, &nListCount);
ProtocolModule_Packet_UserList(tszPKTBuffer, &nPKTLen, &ppSt_UserInfo, nListCount);
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_UserInfo, nListCount);
BaseLib_OperatorString_GetKeyValue(pptszListHdr[2], "=", tszKey, st_MQProtocol.tszMQKey);
BaseLib_OperatorString_GetKeyValue(pptszListHdr[3], "=", tszKey, tszValue);
st_MQProtocol.nSerial = _ttxoll(tszValue);
XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,发送的获取用户列表请求成功,获取到的用户列表个数:%d"), lpszClientAddr, nListCount);
}
else if (0 == _tcsxnicmp(lpszAPITopic, tszValue, _tcsxlen(lpszAPITopic)))
{
//主题 http://127.0.0.1:5202/api?function=get&method=topic
int nListCount = 0;
XCHAR** ppszTableName;
DBModule_MQData_ShowTable(&ppszTableName, &nListCount);
ProtocolModule_Packet_TopicList(tszPKTBuffer, &nPKTLen, &ppszTableName, nListCount);
BaseLib_OperatorMemory_Free((XPPPMEM)&ppszTableName, nListCount);
MessageQueue_TCP_Handle(&st_ProtocolHdr, lpszClientAddr, (LPCXSTR)&st_MQProtocol, sizeof(XENGINE_PROTOCOL_XMQ), XENGINE_MQAPP_NETTYPE_HTTP);
XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,发送的获取主题列表请求成功,获取到的主题列表个数:%d"), lpszClientAddr, nListCount);
}
}
}
else
{
......
......@@ -74,11 +74,6 @@ void CALLBACK MessageQueue_Callback_WSLeave(LPCXSTR lpszClientAddr, XSOCKET hSoc
XEngine_MQXService_Close(lpszClientAddr, XENGINE_MQAPP_NETTYPE_WEBSOCKET, false);
}
//////////////////////////////////////////////////////////////////////////
void CALLBACK MessageQueue_Callback_Timeout(LPCXSTR lpszClientAddr, LPCXSTR lpszClientUser, ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType, XPVOID lParam)
{
XEngine_MQXService_Close(lpszClientAddr, XENGINE_MQAPP_NETTYPE_HTTP, true);
}
//////////////////////////////////////////////////////////////////////////
void XEngine_MQXService_Close(LPCXSTR lpszClientAddr, int nIPProto, bool bHeart)
{
if (XENGINE_MQAPP_NETTYPE_TCP == nIPProto)
......
......@@ -12,7 +12,5 @@ bool CALLBACK MessageQueue_Callback_WSLogin(LPCXSTR lpszClientAddr, XSOCKET hSoc
void CALLBACK MessageQueue_Callback_WSRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam);
void CALLBACK MessageQueue_Callback_WSLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam);
void CALLBACK MessageQueue_Callback_Timeout(LPCXSTR lpszClientAddr, LPCXSTR lpszClientUser, ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType, XPVOID lParam);
void XEngine_MQXService_Close(LPCXSTR lpszClientAddr, int nIPProto, bool bHeart);
bool XEngine_MQXService_Send(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, int nIPProto);
\ No newline at end of file
......@@ -12,7 +12,7 @@ XHTHREAD CALLBACK MessageQueue_TCPThread(XPVOID lParam)
}
int nListCount = 0;
XENGINE_PROTOCOLHDR st_ProtocolHdr;;
HELPCOMPONENT_PACKET_CLIENT** ppSst_ListAddr;
XENGINE_MANAGEPOOL_TASKEVENT** ppSst_ListAddr;
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
......@@ -39,19 +39,12 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
int nSDLen = 10240;
LPCXSTR lpszClientType;
XCHAR tszSDBuffer[10240];
XCHAR tszSessionStr[MAX_PATH];
memset(tszSessionStr, '\0', MAX_PATH);
memset(tszSDBuffer, '\0', sizeof(tszSDBuffer));
if (XENGINE_MQAPP_NETTYPE_TCP == nNetType)
{
lpszClientType = _X("TCP");
}
else if (XENGINE_MQAPP_NETTYPE_HTTP == nNetType)
{
lpszClientType = _X("HTTP");
}
else
{
lpszClientType = _X("WEBSOCKET");
......@@ -61,17 +54,8 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
{
if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_HB_SYN == pSt_ProtocolHdr->unOperatorCode)
{
if (XENGINE_MQAPP_NETTYPE_HTTP == nNetType)
{
_xstprintf(tszSessionStr, _X("%lld"), pSt_ProtocolHdr->xhToken);
}
else
{
_tcsxcpy(tszSessionStr, lpszClientAddr);
}
SessionModule_Client_Heart(tszSessionStr);
//如果设置了标志位或者是HTTP请求,那么返回消息
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->unPacketSize = 0;
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_HB_ACK;
......@@ -96,6 +80,14 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
memset(&st_ProtocolAuth, '\0', sizeof(XENGINE_PROTOCOL_USERAUTH));
memcpy(&st_ProtocolAuth, lpszMsgBuffer, sizeof(XENGINE_PROTOCOL_USERAUTH));
if (SessionModule_Client_GetAddr(st_ProtocolAuth.tszUserName))
{
pSt_ProtocolHdr->wReserve = 700;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求登录到服务失败,因为用户已经登录了"), lpszClientType, lpszClientAddr);
return false;
}
_tcsxcpy(st_UserInfo.tszUserName, st_ProtocolAuth.tszUserName);
_tcsxcpy(st_UserInfo.tszUserPass, st_ProtocolAuth.tszUserPass);
......@@ -121,7 +113,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求远程验证失败,HTTPCode:%d"), lpszClientType, lpszClientAddr, nHTTPCode);
return false;
}
ProtocolModule_Parse_Http(ptszSDBuffer, nSDLen, NULL, (XCHAR*)&st_UserInfo, &nRVLen);
ProtocolModule_Parse_Websocket(ptszSDBuffer, nSDLen, NULL, (XCHAR*)&st_UserInfo, &nRVLen);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszSDBuffer);
}
else
......@@ -137,18 +129,8 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
st_UserInfo.nUserState = 1;
DBModule_MQUser_UserUPDate(&st_UserInfo);
}
if (XENGINE_MQAPP_NETTYPE_HTTP == nNetType)
{
//HTTP使用SESSION
BaseLib_OperatorHandle_Create(&pSt_ProtocolHdr->xhToken);
_xstprintf(tszSessionStr, _X("%lld"), pSt_ProtocolHdr->xhToken);
SessionModule_Client_Create(tszSessionStr, st_UserInfo.tszUserName, nNetType);
}
else
{
SessionModule_Client_Create(lpszClientAddr, st_UserInfo.tszUserName, nNetType);
}
pSt_ProtocolHdr->wReserve = 0;
SessionModule_Client_Create(lpszClientAddr, &st_UserInfo, nNetType);
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s客户端:%s,请求验证成功,用户名:%s,密码:%s"), lpszClientType, lpszClientAddr, st_ProtocolAuth.tszUserName, st_ProtocolAuth.tszUserPass);
......@@ -156,11 +138,59 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUSEROUT == pSt_ProtocolHdr->unOperatorCode)
{
XENGINE_PROTOCOL_USERAUTH st_ProtocolAuth;
XENGINE_PROTOCOL_USERINFO st_ProtocolInfo;
memset(&st_ProtocolAuth, '\0', sizeof(XENGINE_PROTOCOL_USERAUTH));
memset(&st_ProtocolInfo, '\0', sizeof(XENGINE_PROTOCOL_USERINFO));
memcpy(&st_ProtocolAuth, lpszMsgBuffer, sizeof(XENGINE_PROTOCOL_USERAUTH));
if (!SessionModule_Client_GetInfoByUser(st_ProtocolAuth.tszUserName, &st_ProtocolInfo))
{
pSt_ProtocolHdr->wReserve = 711;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求登出失败,没有找到用户,可能用户没有登录,错误:%lX"), lpszClientType, lpszClientAddr, SessionModule_GetLastError());
return false;
}
//判断用户是否正确
if (0 == _tcsxncmp(st_ProtocolInfo.tszUserName, st_ProtocolAuth.tszUserPass, _tcsxlen(st_ProtocolInfo.tszUserName)) && (0 == _tcsxncmp(st_ProtocolInfo.tszUserPass, st_ProtocolAuth.tszUserPass, _tcsxlen(st_ProtocolInfo.tszUserPass))))
{
//是否需要通知
if (_tcsxlen(st_ServiceCfg.st_XPass.tszPassLogout) > 0)
{
int nSDLen = 0;
int nHTTPCode = 0;
XCHAR tszSDBuffer[1024];
NETHELP_HTTPCLIENT st_HTTPParament;
XENGINE_PROTOCOL_USERAUTH st_ProtocolAuth;
memset(tszSDBuffer, '\0', sizeof(tszSDBuffer));
memset(&st_HTTPParament, '\0', sizeof(NETHELP_HTTPCLIENT));
memset(&st_ProtocolAuth, '\0', sizeof(XENGINE_PROTOCOL_USERAUTH));
st_HTTPParament.nTimeConnect = 2;
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s客户端:%s,用户登出成功,暂时没有作用,用户名:%s,密码:%s"), lpszClientType, lpszClientAddr, st_ProtocolAuth.tszUserName, st_ProtocolAuth.tszUserPass);
ProtocolModule_Packet_PassAuth(&st_ProtocolAuth, tszSDBuffer, &nSDLen, XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUSEROUT);
APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XPass.tszPassLogout, tszSDBuffer, &nHTTPCode, NULL, NULL, NULL, NULL, &st_HTTPParament);
if (200 == nHTTPCode)
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s客户端:%s,请求远程注销成功"), lpszClientType, lpszClientAddr);
}
else
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求远程注销失败,HTTPCode:%d"), lpszClientType, lpszClientAddr, nHTTPCode);
}
}
st_ProtocolInfo.nUserState = 0;
DBModule_MQUser_UserUPDate(&st_ProtocolInfo);
SessionModule_Client_DeleteByUser(st_ProtocolAuth.tszUserName);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s客户端:%s,用户登出成功,用户名:%s,密码:%s"), lpszClientType, lpszClientAddr, st_ProtocolAuth.tszUserName, st_ProtocolAuth.tszUserPass);
}
else
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,用户登出失败,用户或密码错误,用户名:%s,密码:%s"), lpszClientType, lpszClientAddr, st_ProtocolAuth.tszUserName, st_ProtocolAuth.tszUserPass);
}
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUSERREG == pSt_ProtocolHdr->unOperatorCode)
{
......@@ -277,28 +307,13 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
memset(&st_MQProtocol, '\0', sizeof(XENGINE_PROTOCOL_XMQ));
memset(tszUserName, '\0', MAX_PATH);
if (XENGINE_MQAPP_NETTYPE_HTTP == nNetType)
{
_xstprintf(tszSessionStr, _X("%lld"), pSt_ProtocolHdr->xhToken);
if (!SessionModule_Client_GetUser(tszSessionStr, tszUserName))
{
pSt_ProtocolHdr->wReserve = 700;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求失败,用户没有通过验证,Session:%s"), lpszClientType, lpszClientAddr, tszSessionStr);
return false;
}
}
else
if (!SessionModule_Client_GetUser(lpszClientAddr, tszUserName))
{
if (!SessionModule_Client_GetUser(lpszClientAddr, tszUserName))
{
pSt_ProtocolHdr->wReserve = 700;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求失败,用户没有通过验证"), lpszClientType, lpszClientAddr);
return false;
}
pSt_ProtocolHdr->wReserve = 700;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,请求失败,用户没有通过验证"), lpszClientType, lpszClientAddr);
return false;
}
memcpy(&st_MQProtocol, lpszMsgBuffer, sizeof(XENGINE_PROTOCOL_XMQ));
......@@ -339,7 +354,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
if (DBModule_MQData_Query(&st_DBIndex))
{
//找到了返回错误
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 701;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -383,7 +398,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
//插入数据库
if (!DBModule_MQData_Insert(&st_DBQueue))
{
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 702;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -393,7 +408,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
return false;
}
//返回成功没如果需要
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 0;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -520,7 +535,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
//创建表
if (!DBModule_MQData_CreateTable(st_MQProtocol.tszMQKey))
{
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 751;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -538,7 +553,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
if (!DBModule_MQUser_OwnerInsert(&st_DBOwner))
{
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 752;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -548,7 +563,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
return false;
}
//回复
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 0;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -575,7 +590,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
if (!DBModule_MQUser_OwnerDelete(&st_DBOwner))
{
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 761;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -588,7 +603,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
DBModule_MQData_DeleteTable(st_MQProtocol.tszMQKey);
DBModule_MQUser_KeyDelete(&st_UserKey);
DBModule_MQUser_TimeDelete(&st_DBInfo);
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 0;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......@@ -637,6 +652,29 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s消息端:%s,请求设置序列号成功,主题名称:%s,序列号:%lld"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial);
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICUNBIND == pSt_ProtocolHdr->unOperatorCode)
{
pSt_ProtocolHdr->wReserve = 0;
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICUNBIND;
XENGINE_DBUSERKEY st_Userkey;
memset(&st_Userkey, '\0', sizeof(XENGINE_DBUSERKEY));
_tcsxcpy(st_Userkey.tszUserName, tszUserName);
_tcsxcpy(st_Userkey.tszKeyName, st_MQProtocol.tszMQKey);
if (!DBModule_MQUser_KeyDelete(&st_Userkey))
{
pSt_ProtocolHdr->wReserve = 721;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,解除消息绑定订阅失败,可能没有找到主题用户,主题名称:%s,用户名称:%s,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, tszUserName, DBModule_GetLastError());
return false;
}
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("%s消息端:%s,解除消息绑定成功,主题名称:%s,序列号:%lld"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey);
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQNUMBER == pSt_ProtocolHdr->unOperatorCode)
{
XENGINE_DBMESSAGEQUEUE st_DBStart;
......@@ -680,7 +718,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
if (!DBModule_MQUser_OwnerQuery(&st_DBOwner))
{
if (pSt_ProtocolHdr->byIsReply || (XENGINE_MQAPP_NETTYPE_HTTP == nNetType))
if (pSt_ProtocolHdr->byIsReply)
{
pSt_ProtocolHdr->wReserve = 781;
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
......
......@@ -11,7 +11,7 @@ XHTHREAD CALLBACK MessageQueue_WebsocketThread(XPVOID lParam)
continue;
}
int nListCount = 0;
RFCCOMPONENTS_WSPKT_CLIENT** ppSst_ListAddr;
XENGINE_MANAGEPOOL_TASKEVENT** ppSst_ListAddr;
RfcComponents_WSPacket_GetPoolEx(xhWSPacket, nThreadPos, &ppSst_ListAddr, &nListCount);
for (int i = 0; i < nListCount; i++)
......@@ -43,7 +43,7 @@ bool MessageQueue_Websocket_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
ProtocolModule_Parse_Http(lpszMsgBuffer, nMsgLen, &st_ProtocolHdr, tszMsgBuffer, &nPLen);
ProtocolModule_Parse_Websocket(lpszMsgBuffer, nMsgLen, &st_ProtocolHdr, tszMsgBuffer, &nPLen);
MessageQueue_TCP_Handle(&st_ProtocolHdr, lpszClientAddr, tszMsgBuffer, nPLen, XENGINE_MQAPP_NETTYPE_WEBSOCKET);
}
else
......
......@@ -147,12 +147,12 @@ int main(int argc, char** argv)
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化数据库服务成功"));
if (!SessionModule_Client_Init(st_ServiceCfg.st_XTime.nSessionTime, MessageQueue_Callback_Timeout))
if (!SessionModule_Client_Init())
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("初始化客户端会话管理器失败,错误:%lX"), SessionModule_GetLastError());
goto NETSERVICEEXIT;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化客户端会话管理器成功,会话超时时间:%d 秒"), st_ServiceCfg.st_XTime.nSessionTime);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化客户端会话管理器成功"));
if (st_ServiceCfg.nTCPPort > 0)
{
......
......@@ -33,8 +33,11 @@
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICMODIFY 0x7015 //主题名修改回复
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICBIND 0x7016 //请求主题绑定操作
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICBIND 0x7017 //回复
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICUNBIND 0x7018 //请求主题解绑操作
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPTOPICUNBIND 0x7019 //回复
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQMSGMODIFY 0x7020 //消息修改请求
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPMSGMODIFY 0x7021 //消息修改回复
//用户协议
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUSERLOG 0x7020 //用户登录
#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPUSERLOG 0x7021
......