Skip to content

Commit 193dedd

Browse files
committed
delete:repeated function for session module
modify:callback function has more parament
1 parent b0f0d19 commit 193dedd

File tree

5 files changed

+8
-81
lines changed

5 files changed

+8
-81
lines changed

XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ EXPORTS
77
SessionModule_Client_Destory
88
SessionModule_Client_Create
99
SessionModule_Client_Delete
10-
SessionModule_Client_GetAuth
1110
SessionModule_Client_GetUser
1211
SessionModule_Client_Heart
1312

XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -149,50 +149,6 @@ BOOL CSessionModule_Client::SessionModule_Client_Delete(LPCTSTR lpszClientAddr)
149149
return TRUE;
150150
}
151151
/************************************************************************
152-
函数名称:SessionModule_Client_GetAuth
153-
函数功能:获得客户端是否登录
154-
参数.一:lpszClientAddr
155-
In/Out:In
156-
类型:常量字符指针
157-
可空:N
158-
意思:输入客户端信息
159-
参数.二:ptszUserName
160-
In/Out:Out
161-
类型:字符指针
162-
可空:Y
163-
意思:输出对应的用户名
164-
返回值
165-
类型:逻辑型
166-
意思:是否成功
167-
备注:
168-
************************************************************************/
169-
BOOL CSessionModule_Client::SessionModule_Client_GetAuth(LPCTSTR lpszClientAddr, TCHAR* ptszUserName /* = NULL */)
170-
{
171-
Session_IsErrorOccur = FALSE;
172-
173-
if (NULL == lpszClientAddr)
174-
{
175-
Session_IsErrorOccur = TRUE;
176-
Session_dwErrorCode = ERROR_MQ_MODULE_SESSION_PARAMENT;
177-
return FALSE;
178-
}
179-
st_Locker.lock_shared();
180-
unordered_map<tstring, XENGINE_SESSIONINFO>::iterator stl_MapIterator = stl_MapSession.find(lpszClientAddr);
181-
if (stl_MapIterator == stl_MapSession.end())
182-
{
183-
Session_IsErrorOccur = TRUE;
184-
Session_dwErrorCode = ERROR_MQ_MODULE_SESSION_NOTFOUND;
185-
st_Locker.unlock_shared();
186-
return FALSE;
187-
}
188-
if (NULL != ptszUserName)
189-
{
190-
_tcscpy(ptszUserName, stl_MapIterator->second.tszUserName);
191-
}
192-
st_Locker.unlock_shared();
193-
return TRUE;
194-
}
195-
/************************************************************************
196152
函数名称:SessionModule_Client_GetUser
197153
函数功能:通过会话ID获取用户
198154
参数.一:lpszSessionStr
@@ -279,23 +235,19 @@ XHTHREAD CALLBACK CSessionModule_Client::SessionModule_Client_Thread(LPVOID lPar
279235
{
280236
CSessionModule_Client* pClass_This = (CSessionModule_Client*)lParam;
281237

282-
list<tstring> stl_ListClient;
238+
list<XENGINE_SESSIONINFO> stl_ListClient;
283239
while (pClass_This->bRun)
284240
{
285241
pClass_This->st_Locker.lock_shared();
286242
unordered_map<tstring, XENGINE_SESSIONINFO>::const_iterator stl_MapIterator = pClass_This->stl_MapSession.begin();
287243
for (; stl_MapIterator != pClass_This->stl_MapSession.end(); stl_MapIterator++)
288244
{
289-
//目前仅仅支持HTTP客户端会话超时
290-
if (XENGINE_MQAPP_NETTYPE_HTTP == stl_MapIterator->second.nNetType)
245+
time_t nTimeEnd = time(NULL);
246+
if ((nTimeEnd - stl_MapIterator->second.nTimeStart) > pClass_This->nSessionTime)
291247
{
292-
time_t nTimeEnd = time(NULL);
293-
if ((nTimeEnd - stl_MapIterator->second.nTimeStart) > pClass_This->nSessionTime)
294-
{
295-
//移除客户端
296-
stl_ListClient.push_back(stl_MapIterator->first.c_str());
297-
break;
298-
}
248+
//移除客户端
249+
stl_ListClient.push_back(stl_MapIterator->second);
250+
break;
299251
}
300252
}
301253
pClass_This->st_Locker.unlock_shared();
@@ -304,7 +256,7 @@ XHTHREAD CALLBACK CSessionModule_Client::SessionModule_Client_Thread(LPVOID lPar
304256
{
305257
for (auto stl_ListIterator = stl_ListClient.begin(); stl_ListIterator != stl_ListClient.end(); stl_ListIterator++)
306258
{
307-
pClass_This->lpCall_Timeout(stl_ListIterator->c_str(), pClass_This->m_lParam);
259+
pClass_This->lpCall_Timeout(stl_ListIterator->tszUserAddr, stl_ListIterator->tszUserName, (ENUM_MQCORE_SESSION_CLIENT_TYPE)stl_ListIterator->nNetType, pClass_This->m_lParam);
308260
}
309261
}
310262
std::this_thread::sleep_for(std::chrono::seconds(1));

XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class CSessionModule_Client
2828
BOOL SessionModule_Client_Destory();
2929
BOOL SessionModule_Client_Create(LPCTSTR lpszClientAddr, LPCTSTR lpszUserName, int nNetType);
3030
BOOL SessionModule_Client_Delete(LPCTSTR lpszClientAddr);
31-
BOOL SessionModule_Client_GetAuth(LPCTSTR lpszClientAddr, TCHAR* ptszUserName = NULL);
3231
BOOL SessionModule_Client_GetUser(LPCTSTR lpszSessionStr, TCHAR* ptszUserName = NULL);
3332
BOOL SessionModule_Client_Heart(LPCTSTR lpszClientAddr);
3433
protected:

XEngine_Source/MQCore_SessionModule/Session_Define.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typedef struct
3131
//////////////////////////////////////////////////////////////////////////
3232
// 导出回调函数
3333
//////////////////////////////////////////////////////////////////////////
34-
typedef void(CALLBACK* CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT)(LPCSTR lpszSessionStr, LPVOID lParam);
34+
typedef void(CALLBACK* CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT)(LPCSTR lpszClientAddr, LPCTSTR lpszClientUser, ENUM_MQCORE_SESSION_CLIENT_TYPE enClientType, LPVOID lParam);
3535
//////////////////////////////////////////////////////////////////////////
3636
// 导出函数
3737
//////////////////////////////////////////////////////////////////////////
@@ -111,25 +111,6 @@ extern "C" BOOL SessionModule_Client_Create(LPCTSTR lpszClientAddr, LPCTSTR lpsz
111111
*********************************************************************/
112112
extern "C" BOOL SessionModule_Client_Delete(LPCTSTR lpszClientAddr);
113113
/************************************************************************
114-
函数名称:SessionModule_Client_GetAuth
115-
函数功能:获得客户端是否登录
116-
参数.一:lpszClientAddr
117-
In/Out:In
118-
类型:常量字符指针
119-
可空:N
120-
意思:输入客户端信息
121-
参数.二:ptszUserName
122-
In/Out:Out
123-
类型:字符指针
124-
可空:Y
125-
意思:输出对应的用户名
126-
返回值
127-
类型:逻辑型
128-
意思:是否成功
129-
备注:
130-
************************************************************************/
131-
extern "C" BOOL SessionModule_Client_GetAuth(LPCTSTR lpszClientAddr, TCHAR * ptszUserName = NULL);
132-
/************************************************************************
133114
函数名称:SessionModule_Client_GetUser
134115
函数功能:通过会话ID获取用户
135116
参数.一:lpszSessionStr

XEngine_Source/MQCore_SessionModule/pch.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ extern "C" BOOL SessionModule_Client_Delete(LPCTSTR lpszClientAddr)
4747
{
4848
return m_SessionClient.SessionModule_Client_Delete(lpszClientAddr);
4949
}
50-
extern "C" BOOL SessionModule_Client_GetAuth(LPCTSTR lpszClientAddr, TCHAR * ptszUserName)
51-
{
52-
return m_SessionClient.SessionModule_Client_GetAuth(lpszClientAddr, ptszUserName);
53-
}
5450
extern "C" BOOL SessionModule_Client_GetUser(LPCTSTR lpszSessionStr, TCHAR * ptszUserName)
5551
{
5652
return m_SessionClient.SessionModule_Client_GetUser(lpszSessionStr, ptszUserName);

0 commit comments

Comments
 (0)