Skip to content

Commit 3c8786b

Browse files
committed
added:get all information for session module
1 parent 129a2b2 commit 3c8786b

File tree

8 files changed

+164
-1
lines changed

8 files changed

+164
-1
lines changed

XEngine_Source/StorageModule_Session/Session_Define.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,30 @@ extern "C" BOOL Session_DLStroage_GetCount(int nPool, list<string>*pStl_ListClie
258258
*********************************************************************/
259259
extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError = TRUE, SESSION_STORAGEDYNAMICRATE * pSt_StorageRate = NULL);
260260
/********************************************************************
261+
函数名称:Session_DLStorage_GetAll
262+
函数功能:获取指定下载池的任务列表
263+
参数.一:nPool
264+
In/Out:In
265+
类型:整数型
266+
可空:N
267+
意思:输入要获取的任务池ID
268+
参数.二:pppSt_StorageInfo
269+
In/Out:Out
270+
类型:三级指针
271+
可空:N
272+
意思:输出获取到的下载信息列表
273+
参数.三:pInt_ListCount
274+
In/Out:Out
275+
类型:整数型指针
276+
可空:N
277+
意思:输出获取到的列表个数
278+
返回值
279+
类型:逻辑型
280+
意思:是否成功
281+
备注:
282+
*********************************************************************/
283+
extern "C" BOOL Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
284+
/********************************************************************
261285
函数名称:Session_DLStroage_Delete
262286
函数功能:删除一个队列
263287
参数.一:lpszClientAddr
@@ -405,6 +429,25 @@ extern "C" BOOL Session_UPStroage_Write(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgB
405429
*********************************************************************/
406430
extern "C" BOOL Session_UPStroage_Exist(LPCTSTR lpszClientAddr);
407431
/********************************************************************
432+
函数名称:Session_UPStorage_GetAll
433+
函数功能:获取所有上传信息
434+
参数.一:pppSt_StorageInfo
435+
In/Out:Out
436+
类型:三级指针
437+
可空:N
438+
意思:输出获取到的上传信息列表
439+
参数.二:pInt_ListCount
440+
In/Out:Out
441+
类型:整数型指针
442+
可空:N
443+
意思:输出获取到的列表个数
444+
返回值
445+
类型:逻辑型
446+
意思:是否成功
447+
备注:
448+
*********************************************************************/
449+
extern "C" BOOL Session_UPStorage_GetAll(SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
450+
/********************************************************************
408451
函数名称:Session_UPStroage_Delete
409452
函数功能:删除上传会话
410453
参数.一:lpszClientAddr

XEngine_Source/StorageModule_Session/Session_Error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
#define ERROR_STORAGE_MODULE_SESSION_EXIST 0x0010002
1818
#define ERROR_STORAGE_MODULE_SESSION_OPENFILE 0x0010003
1919
#define ERROR_STORAGE_MODULE_SESSION_NOTFOUND 0x0010004
20-
#define ERROR_STORAGE_MODULE_SESSION_PASSWORD 0x0010005
20+
#define ERROR_STORAGE_MODULE_SESSION_PASSWORD 0x0010005
21+
#define ERROR_STORAGE_MODULE_SESSION_EMPTY 0x0010006

XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,66 @@ BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int n
528528
return TRUE;
529529
}
530530
/********************************************************************
531+
函数名称:Session_DLStorage_GetAll
532+
函数功能:获取指定下载池的任务列表
533+
参数.一:nPool
534+
In/Out:In
535+
类型:整数型
536+
可空:N
537+
意思:输入要获取的任务池ID
538+
参数.二:pppSt_StorageInfo
539+
In/Out:Out
540+
类型:三级指针
541+
可空:N
542+
意思:输出获取到的下载信息列表
543+
参数.三:pInt_ListCount
544+
In/Out:Out
545+
类型:整数型指针
546+
可空:N
547+
意思:输出获取到的列表个数
548+
返回值
549+
类型:逻辑型
550+
意思:是否成功
551+
备注:
552+
*********************************************************************/
553+
BOOL CSession_DLStroage::Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount)
554+
{
555+
Session_IsErrorOccur = FALSE;
556+
557+
if ((NULL == pppSt_StorageInfo) || (NULL == pInt_ListCount))
558+
{
559+
Session_IsErrorOccur = TRUE;
560+
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PARAMENT;
561+
return FALSE;
562+
}
563+
564+
BOOL bFound = FALSE;
565+
st_Locker.lock_shared();
566+
unordered_map<int, SESSION_STORAGELIST>::iterator stl_MapIterator = stl_MapStroage.find(nPool);
567+
if (stl_MapIterator != stl_MapStroage.end())
568+
{
569+
*pInt_ListCount = stl_MapIterator->second.pStl_ListStorage->size();
570+
BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_StorageInfo, *pInt_ListCount, sizeof(SESSION_STORAGELIST));
571+
572+
stl_MapIterator->second.st_Locker->lock_shared();
573+
list<SESSION_STORAGEINFO>::iterator stl_ListIterator = stl_MapIterator->second.pStl_ListStorage->begin();
574+
for (int i = 0; stl_ListIterator != stl_MapIterator->second.pStl_ListStorage->end(); stl_ListIterator++, i++)
575+
{
576+
*(*pppSt_StorageInfo)[i] = *stl_ListIterator;
577+
}
578+
stl_MapIterator->second.st_Locker->unlock_shared();
579+
}
580+
st_Locker.unlock_shared();
581+
582+
if (*pInt_ListCount <= 0)
583+
{
584+
Session_IsErrorOccur = TRUE;
585+
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_EMPTY;
586+
return FALSE;
587+
}
588+
return TRUE;
589+
}
590+
/********************************************************************
531591
函数名称:Session_DLStroage_Delete
532592
函数功能:删除一个队列
533593
参数.一:lpszClientAddr

XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class CSession_DLStroage
3131
BOOL Session_DLStroage_GetInfo(int nPool, LPCTSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo);
3232
BOOL Session_DLStroage_GetCount(int nPool, list<string>* pStl_ListClient);
3333
BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError = TRUE, SESSION_STORAGEDYNAMICRATE* pSt_StorageRate = NULL);
34+
BOOL Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
3435
BOOL Session_DLStroage_Delete(LPCTSTR lpszClientAddr);
3536
private:
3637
int m_nTryTime;

XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,53 @@ BOOL CSession_UPStroage::Session_UPStroage_Exist(LPCTSTR lpszClientAddr)
320320
return bRet;
321321
}
322322
/********************************************************************
323+
函数名称:Session_UPStorage_GetAll
324+
函数功能:获取所有上传信息
325+
参数.一:pppSt_StorageInfo
326+
In/Out:Out
327+
类型:三级指针
328+
可空:N
329+
意思:输出获取到的上传信息列表
330+
参数.二:pInt_ListCount
331+
In/Out:Out
332+
类型:整数型指针
333+
可空:N
334+
意思:输出获取到的列表个数
335+
返回值
336+
类型:逻辑型
337+
意思:是否成功
338+
备注:
339+
*********************************************************************/
340+
BOOL CSession_UPStroage::Session_UPStorage_GetAll(SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount)
341+
{
342+
Session_IsErrorOccur = FALSE;
343+
344+
if ((NULL == pppSt_StorageInfo) || (NULL == pInt_ListCount))
345+
{
346+
Session_IsErrorOccur = TRUE;
347+
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PARAMENT;
348+
return FALSE;
349+
}
350+
351+
st_Locker.lock_shared();
352+
*pInt_ListCount = stl_MapStroage.size();
353+
BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_StorageInfo, *pInt_ListCount, sizeof(SESSION_STORAGEINFO));
354+
unordered_map<tstring, SESSION_STORAGEUPLOADER>::iterator stl_MapIterator = stl_MapStroage.begin();
355+
for (int i = 0; stl_MapIterator != stl_MapStroage.end(); stl_MapIterator++, i++)
356+
{
357+
*(*pppSt_StorageInfo)[i] = stl_MapIterator->second.st_StorageInfo;
358+
}
359+
st_Locker.unlock_shared();
360+
361+
if (0 == *pInt_ListCount)
362+
{
363+
Session_IsErrorOccur = TRUE;
364+
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_EMPTY;
365+
return FALSE;
366+
}
367+
return TRUE;
368+
}
369+
/********************************************************************
323370
函数名称:Session_UPStroage_Delete
324371
函数功能:删除上传会话
325372
参数.一:lpszClientAddr

XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CSession_UPStroage
2929
BOOL Session_UPStroage_GetInfo(LPCTSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo);
3030
BOOL Session_UPStroage_Write(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen);
3131
BOOL Session_UPStroage_Exist(LPCTSTR lpszClientAddr);
32+
BOOL Session_UPStorage_GetAll(SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
3233
BOOL Session_UPStroage_Delete(LPCTSTR lpszClientAddr);
3334
private:
3435
shared_mutex st_Locker;

XEngine_Source/StorageModule_Session/StorageModule_Session.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ EXPORTS
1414
Session_DLStroage_GetInfo
1515
Session_DLStroage_GetCount
1616
Session_DLStorage_SetSeek
17+
Session_DLStorage_GetAll
1718
Session_DLStroage_Delete
1819

1920
Session_UPStroage_Init
@@ -23,4 +24,5 @@ EXPORTS
2324
Session_UPStroage_GetInfo
2425
Session_UPStroage_Write
2526
Session_UPStroage_Exist
27+
Session_UPStorage_GetAll
2628
Session_UPStroage_Delete

XEngine_Source/StorageModule_Session/pch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOO
7676
{
7777
return m_DLStorage.Session_DLStorage_SetSeek(lpszClientAddr, nSeek, bError, pSt_StorageRate);
7878
}
79+
extern "C" BOOL Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO * **pppSt_StorageInfo, int* pInt_ListCount)
80+
{
81+
return m_DLStorage.Session_DLStorage_GetAll(nPool, pppSt_StorageInfo, pInt_ListCount);
82+
}
7983
extern "C" BOOL Session_DLStroage_Delete(LPCTSTR lpszClientAddr)
8084
{
8185
return m_DLStorage.Session_DLStroage_Delete(lpszClientAddr);
@@ -108,6 +112,10 @@ extern "C" BOOL Session_UPStroage_Exist(LPCTSTR lpszClientAddr)
108112
{
109113
return m_UPStorage.Session_UPStroage_Exist(lpszClientAddr);
110114
}
115+
extern "C" BOOL Session_UPStorage_GetAll(SESSION_STORAGEINFO * **pppSt_StorageInfo, int* pInt_ListCount)
116+
{
117+
return m_UPStorage.Session_UPStorage_GetAll(pppSt_StorageInfo, pInt_ListCount);
118+
}
111119
extern "C" BOOL Session_UPStroage_Delete(LPCTSTR lpszClientAddr)
112120
{
113121
return m_UPStorage.Session_UPStroage_Delete(lpszClientAddr);

0 commit comments

Comments
 (0)