Skip to content

Commit 52d44b6

Browse files
committed
modify:ModuleSession_Forward_Get supported addr whether login
modify:forward must be login now
1 parent 71a9e09 commit 52d44b6

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ extern "C" bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR * ptszDstAd
116116
参数.二:ptszDstAddr
117117
In/Out:Out
118118
类型:字符指针
119-
可空:N
119+
可空:Y
120120
意思:输出对端地址
121121
返回值
122122
类型:逻辑型
123123
意思:是否成功
124124
备注:
125125
*********************************************************************/
126-
extern "C" bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr);
126+
extern "C" bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr = NULL);

XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ bool CModuleSession_Forward::ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHA
253253
参数.二:ptszDstAddr
254254
In/Out:Out
255255
类型:字符指针
256-
可空:N
256+
可空:Y
257257
意思:输出对端地址
258258
返回值
259259
类型:逻辑型
@@ -280,6 +280,11 @@ bool CModuleSession_Forward::ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR*
280280
st_Locker.unlock_shared();
281281
return false;
282282
}
283+
if (NULL == ptszDstAddr)
284+
{
285+
st_Locker.unlock_shared();
286+
return true;
287+
}
283288
//如果有转发,需要清理对方的转发设置
284289
if (!stl_MapIterator->second.bForward)
285290
{

XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CModuleSession_Forward
2121
bool ModuleSession_Forward_List(SESSION_FORWARD*** pppSt_ListUser, int* pInt_Count, LPCXSTR lpszAddr = NULL);
2222
bool ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr);
2323
bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR* ptszDstAddr = NULL);
24-
bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr);
24+
bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr = NULL);
2525
private:
2626
shared_mutex st_Locker;
2727
private:

XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ bool XEngine_Forward_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n
8282
//处理转发协议
8383
if (ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_USER_FORWARD == pSt_ProtocolHdr->unOperatorType)
8484
{
85+
if (!ModuleSession_Forward_Get(lpszClientAddr))
86+
{
87+
pSt_ProtocolHdr->wReserve = 401;
88+
pSt_ProtocolHdr->unPacketSize = 0;
89+
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREP;
90+
XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD);
91+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,请求转发协议:%d 失败,因为没有登录"), lpszClientAddr, pSt_ProtocolHdr->unOperatorCode);
92+
return false;
93+
}
94+
8595
if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREQ == pSt_ProtocolHdr->unOperatorCode)
8696
{
8797
int nListCount = 0;

0 commit comments

Comments
 (0)