Skip to content

Commit 5c1bf6c

Browse files
committed
modify:protocol name
modify:delete session notify use to bind list
1 parent 6eff473 commit 5c1bf6c

File tree

14 files changed

+125
-274
lines changed

14 files changed

+125
-274
lines changed

XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,14 +442,18 @@ BOOL CDBModule_MQUser::DBModule_MQUser_KeyList(LPCTSTR lpszUser, LPCTSTR lpszKey
442442
TCHAR tszSQLStatement[1024];
443443
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
444444
//名称为,消息名为必填
445-
if (_tcslen(lpszKeyName) > 0)
445+
if ((_tcslen(lpszUser) > 0) && (_tcslen(lpszKeyName) > 0))
446446
{
447447
_stprintf_s(tszSQLStatement, _T("SELECT * FROM `UserKey` WHERE tszKeyUser = '%s' AND tszKeyName = '%s'"), lpszUser, lpszKeyName);
448448
}
449-
else
449+
else if ((_tcslen(lpszUser) > 0) && (_tcslen(lpszKeyName) <= 0))
450450
{
451451
_stprintf_s(tszSQLStatement, _T("SELECT * FROM `UserKey` WHERE tszKeyUser = '%s'"), lpszUser);
452452
}
453+
else if ((_tcslen(lpszUser) <= 0) && (_tcslen(lpszKeyName) > 0))
454+
{
455+
_stprintf_s(tszSQLStatement, _T("SELECT * FROM `UserKey` WHERE tszKeyName = '%s'"), lpszKeyName);
456+
}
453457

454458
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nllLine, &nllRow))
455459
{

XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.def

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ EXPORTS
88
SessionModule_Client_Create
99
SessionModule_Client_Delete
1010
SessionModule_Client_GetUser
11+
SessionModule_Client_GetAddr
1112
SessionModule_Client_GetType
12-
SessionModule_Client_Heart
13-
14-
SessionModule_Notify_Create
15-
SessionModule_Notify_Destory
16-
SessionModule_Notify_Insert
17-
SessionModule_Notify_Delete
18-
SessionModule_Notify_GetList
19-
SessionModule_Notify_DelClient
13+
SessionModule_Client_Heart

XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@
171171
<ClInclude Include="framework.h" />
172172
<ClInclude Include="pch.h" />
173173
<ClInclude Include="SessionModule_Client\SessionModule_Client.h" />
174-
<ClInclude Include="SessionModule_Notify\SessionModule_Notify.h" />
175174
<ClInclude Include="Session_Define.h" />
176175
<ClInclude Include="Session_Error.h" />
177176
</ItemGroup>
@@ -184,7 +183,6 @@
184183
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
185184
</ClCompile>
186185
<ClCompile Include="SessionModule_Client\SessionModule_Client.cpp" />
187-
<ClCompile Include="SessionModule_Notify\SessionModule_Notify.cpp" />
188186
</ItemGroup>
189187
<ItemGroup>
190188
<None Include="MQCore_SessionModule.def" />

XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.vcxproj.filters

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
<Filter Include="源文件\SessionModule_Client">
2020
<UniqueIdentifier>{c7883222-ba6a-4681-af59-553676384789}</UniqueIdentifier>
2121
</Filter>
22-
<Filter Include="源文件\SessionModule_Notify">
23-
<UniqueIdentifier>{63c007ec-b8c8-4015-b0c0-616b6885cf8a}</UniqueIdentifier>
24-
</Filter>
25-
<Filter Include="头文件\SessionModule_Notify">
26-
<UniqueIdentifier>{0d02b2a6-4fc5-4c48-afeb-28053ac7e1df}</UniqueIdentifier>
27-
</Filter>
2822
</ItemGroup>
2923
<ItemGroup>
3024
<ClInclude Include="framework.h">
@@ -42,9 +36,6 @@
4236
<ClInclude Include="Session_Error.h">
4337
<Filter>头文件</Filter>
4438
</ClInclude>
45-
<ClInclude Include="SessionModule_Notify\SessionModule_Notify.h">
46-
<Filter>头文件\SessionModule_Notify</Filter>
47-
</ClInclude>
4839
</ItemGroup>
4940
<ItemGroup>
5041
<ClCompile Include="dllmain.cpp">
@@ -56,9 +47,6 @@
5647
<ClCompile Include="SessionModule_Client\SessionModule_Client.cpp">
5748
<Filter>源文件\SessionModule_Client</Filter>
5849
</ClCompile>
59-
<ClCompile Include="SessionModule_Notify\SessionModule_Notify.cpp">
60-
<Filter>源文件\SessionModule_Notify</Filter>
61-
</ClCompile>
6250
</ItemGroup>
6351
<ItemGroup>
6452
<None Include="MQCore_SessionModule.def">

XEngine_Source/MQCore_SessionModule/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LOADBIN =
88
LIB =
99
LIBEX = -ldl -lpthread
1010
LOADSO = -Wl,-rpath=
11-
LIBINCLUDE = SessionModule_Client.o SessionModule_Notify.o pch.o
11+
LIBINCLUDE = SessionModule_Client.o pch.o
1212

1313
ifeq ($(shell uname),Darwin)
1414
SHAREDLL = dylib
@@ -39,8 +39,6 @@ all:$(LIBINCLUDE)
3939

4040
SessionModule_Client.o:./SessionModule_Client/SessionModule_Client.cpp
4141
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./SessionModule_Client/SessionModule_Client.cpp
42-
SessionModule_Notify.o:./SessionModule_Notify/SessionModule_Notify.cpp
43-
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./SessionModule_Notify/SessionModule_Notify.cpp
4442

4543
pch.o:./pch.cpp
4644
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./pch.cpp

XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,55 @@ BOOL CSessionModule_Client::SessionModule_Client_GetUser(LPCTSTR lpszSessionStr,
193193
return TRUE;
194194
}
195195
/********************************************************************
196+
函数名称:SessionModule_Client_GetAddr
197+
函数功能:获取用户地址
198+
参数.一:lpszUserName
199+
In/Out:In
200+
类型:常量字符指针
201+
可空:N
202+
意思:输入用户名
203+
参数.二:ptszUserAddr
204+
In/Out:Out
205+
类型:字符指针
206+
可空:N
207+
意思:输出用户地址
208+
返回值
209+
类型:逻辑型
210+
意思:是否成功
211+
备注:
212+
*********************************************************************/
213+
BOOL CSessionModule_Client::SessionModule_Client_GetAddr(LPCTSTR lpszUserName, TCHAR* ptszUserAddr)
214+
{
215+
Session_IsErrorOccur = FALSE;
216+
217+
if (NULL == lpszUserName)
218+
{
219+
Session_IsErrorOccur = TRUE;
220+
Session_dwErrorCode = ERROR_MQ_MODULE_SESSION_PARAMENT;
221+
return FALSE;
222+
}
223+
BOOL bFound = FALSE;
224+
st_Locker.lock_shared();
225+
for (auto stl_MapIterator = stl_MapSession.begin(); stl_MapIterator != stl_MapSession.end(); stl_MapIterator++)
226+
{
227+
if (0 == _tcsncmp(lpszUserName, stl_MapIterator->second.tszUserName, _tcslen(lpszUserName)))
228+
{
229+
bFound = TRUE;
230+
_tcscpy(ptszUserAddr, stl_MapIterator->second.tszUserAddr);
231+
break;
232+
}
233+
}
234+
st_Locker.unlock_shared();
235+
236+
if (!bFound)
237+
{
238+
Session_IsErrorOccur = TRUE;
239+
Session_dwErrorCode = ERROR_MQ_MODULE_SESSION_NOTFOUND;
240+
return FALSE;
241+
}
242+
return TRUE;
243+
}
244+
/********************************************************************
196245
函数名称:SessionModule_Client_GetType
197246
函数功能:通过客户端获得连接的网络类型
198247
参数.一:lpszSessionStr

XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CSessionModule_Client
2929
BOOL SessionModule_Client_Create(LPCTSTR lpszClientAddr, LPCTSTR lpszUserName, int nNetType);
3030
BOOL SessionModule_Client_Delete(LPCTSTR lpszClientAddr);
3131
BOOL SessionModule_Client_GetUser(LPCTSTR lpszSessionStr, TCHAR* ptszUserName = NULL);
32+
BOOL SessionModule_Client_GetAddr(LPCTSTR lpszUserName, TCHAR* ptszUserAddr);
3233
BOOL SessionModule_Client_GetType(LPCTSTR lpszSessionStr, int* pInt_NetType);
3334
BOOL SessionModule_Client_Heart(LPCTSTR lpszClientAddr);
3435
protected:

XEngine_Source/MQCore_SessionModule/Session_Define.h

Lines changed: 19 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ typedef enum
2121
ENUM_MQCORE_SESSION_CLIENT_TYPE_HTTP = 3
2222
}ENUM_MQCORE_SESSION_CLIENT_TYPE;
2323
//////////////////////////////////////////////////////////////////////////
24-
// 导出的数据结构
25-
//////////////////////////////////////////////////////////////////////////
26-
typedef struct
27-
{
28-
TCHAR tszNotifyAddr[128];
29-
ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType;
30-
}SESSION_NOTIFYCLIENT, * LPSESSION_NOTIFYCLIENT;
31-
//////////////////////////////////////////////////////////////////////////
3224
// 导出回调函数
3325
//////////////////////////////////////////////////////////////////////////
3426
typedef void(CALLBACK* CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT)(LPCSTR lpszClientAddr, LPCTSTR lpszClientUser, ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType, LPVOID lParam);
@@ -130,152 +122,54 @@ extern "C" BOOL SessionModule_Client_Delete(LPCTSTR lpszClientAddr);
130122
************************************************************************/
131123
extern "C" BOOL SessionModule_Client_GetUser(LPCTSTR lpszSessionStr, TCHAR* ptszUserName = NULL);
132124
/********************************************************************
133-
函数名称:SessionModule_Client_GetType
134-
函数功能:通过客户端获得连接的网络类型
135-
参数.一:lpszSessionStr
125+
函数名称:SessionModule_Client_GetAddr
126+
函数功能:获取用户地址
127+
参数.一:lpszUserName
136128
In/Out:In
137129
类型:常量字符指针
138130
可空:N
139-
意思:输入要操作的客户端
140-
参数.二:pInt_NetType
131+
意思:输入用户名
132+
参数.二:ptszUserAddr
141133
In/Out:Out
142-
类型:整数型指针
143-
可空:N
144-
意思:输出网络类型
145-
返回值
146-
类型:逻辑型
147-
意思:是否成功
148-
备注:
149-
*********************************************************************/
150-
extern "C" BOOL SessionModule_Client_GetType(LPCTSTR lpszSessionStr, int* pInt_NetType);
151-
/********************************************************************
152-
函数名称:SessionModule_Client_Heart
153-
函数功能:触发一次心跳
154-
参数.一:lpszClientAddr
155-
In/Out:In
156-
类型:常量字符指针
157-
可空:N
158-
意思:输入要触发的客户端
159-
返回值
160-
类型:逻辑型
161-
意思:是否成功
162-
备注:
163-
*********************************************************************/
164-
extern "C" BOOL SessionModule_Client_Heart(LPCTSTR lpszClientAddr);
165-
/************************************************************************/
166-
/* 订阅 */
167-
/************************************************************************/
168-
/********************************************************************
169-
函数名称:SessionModule_Notify_Create
170-
函数功能:创建主题
171-
参数.一:lpszTopicName
172-
In/Out:In
173-
类型:常量字符指针
174-
可空:N
175-
意思:输入主题名
176-
返回值
177-
类型:逻辑型
178-
意思:是否成功
179-
备注:
180-
*********************************************************************/
181-
extern "C" BOOL SessionModule_Notify_Create(LPCTSTR lpszTopicName);
182-
/********************************************************************
183-
函数名称:SessionModule_Notify_Destory
184-
函数功能:销毁一个主题
185-
参数.一:lpszTopicName
186-
In/Out:In
187-
类型:常量字符指针
134+
类型:字符指针
188135
可空:N
189-
意思:输入主题名
136+
意思:输出用户地址
190137
返回值
191138
类型:逻辑型
192139
意思:是否成功
193140
备注:
194141
*********************************************************************/
195-
extern "C" BOOL SessionModule_Notify_Destory(LPCTSTR lpszTopicName);
196-
/************************************************************************
197-
函数名称:SessionModule_Notify_Insert
198-
函数功能:插入一个订阅客户端到指定主题
199-
参数.一:lpszTopicStr
200-
In/Out:In
201-
类型:常量字符指针
202-
可空:N
203-
意思:输入主题名
204-
参数.二:lpszClientAddr
205-
In/Out:In
206-
类型:常量字符指针
207-
可空:N
208-
意思:输入要插入的客户端
209-
参数.三:enClientType
210-
In/Out:In
211-
类型:枚举型
212-
可空:N
213-
意思:客户端类型
214-
返回值
215-
类型:逻辑型
216-
意思:是否成功
217-
备注:
218-
************************************************************************/
219-
extern "C" BOOL SessionModule_Notify_Insert(LPCTSTR lpszTopicStr, LPCTSTR lpszClientAddr, ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType);
220-
/************************************************************************
221-
函数名称:SessionModule_Notify_Delete
222-
函数功能:从一个主题中删除一个订阅客户端
223-
参数.一:lpszTopicStr
224-
In/Out:In
225-
类型:常量字符指针
226-
可空:N
227-
意思:输入主题名
228-
参数.二:lpszClientAddr
229-
In/Out:In
230-
类型:常量字符指针
231-
可空:N
232-
意思:输入要删除的客户端
233-
参数.三:enClientType
234-
In/Out:In
235-
类型:枚举型
236-
可空:N
237-
意思:客户端类型
238-
返回值
239-
类型:逻辑型
240-
意思:是否成功
241-
备注:
242-
************************************************************************/
243-
extern "C" BOOL SessionModule_Notify_Delete(LPCTSTR lpszTopicStr, LPCTSTR lpszClientAddr, ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType);
142+
extern "C" BOOL SessionModule_Client_GetAddr(LPCTSTR lpszUserName, TCHAR* ptszUserAddr);
244143
/********************************************************************
245-
函数名称:SessionModule_Notify_GetList
246-
函数功能:获取主题对应的订阅列表
247-
参数.一:lpszTopicStr
144+
函数名称:SessionModule_Client_GetType
145+
函数功能:通过客户端获得连接的网络类型
146+
参数.一:lpszSessionStr
248147
In/Out:In
249148
类型:常量字符指针
250149
可空:N
251-
意思:输入主题名
252-
参数.二:pppSt_ListClient
253-
In/Out:Out
254-
类型:三级指针
255-
可空:N
256-
意思:输出客户端地址列表
257-
参数.三:pInt_ListCount
150+
意思:输入要操作的客户端
151+
参数.二:pInt_NetType
258152
In/Out:Out
259153
类型:整数型指针
260154
可空:N
261-
意思:输出列表个数
155+
意思:输出网络类型
262156
返回值
263157
类型:逻辑型
264158
意思:是否成功
265159
备注:
266160
*********************************************************************/
267-
extern "C" BOOL SessionModule_Notify_GetList(LPCTSTR lpszTopicStr, SESSION_NOTIFYCLIENT *** pppSt_ListClient, int* pInt_ListCount);
161+
extern "C" BOOL SessionModule_Client_GetType(LPCTSTR lpszSessionStr, int* pInt_NetType);
268162
/********************************************************************
269-
函数名称:SessionModule_Notify_DelClient
270-
函数功能:删除指定客户端的订阅内容
163+
函数名称:SessionModule_Client_Heart
164+
函数功能:触发一次心跳
271165
参数.一:lpszClientAddr
272166
In/Out:In
273167
类型:常量字符指针
274168
可空:N
275-
意思:输入要删除的客户端
169+
意思:输入要触发的客户端
276170
返回值
277171
类型:逻辑型
278172
意思:是否成功
279173
备注:
280174
*********************************************************************/
281-
extern "C" BOOL SessionModule_Notify_DelClient(LPCTSTR lpszClientAddr);
175+
extern "C" BOOL SessionModule_Client_Heart(LPCTSTR lpszClientAddr);

0 commit comments

Comments
 (0)