Skip to content

Commit d52f4f0

Browse files
committed
fixed:multi login handle is incorrect and tips logged in
1 parent 2e67863 commit d52f4f0

File tree

1 file changed

+52
-66
lines changed

1 file changed

+52
-66
lines changed

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_TCPTask.cpp

Lines changed: 52 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -181,107 +181,93 @@ bool XEngine_Client_TCPTask(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n
181181
}
182182
}
183183
//是否已经登录
184-
if (st_FunSwitch.bSwitchMulti)
185-
{
186-
bool bLogin = false;
187-
int nListCount = 0;
188-
AUTHSESSION_NETCLIENT** ppSt_ListClient;
184+
bool bLogin = false;
185+
int nListCount = 0;
186+
AUTHSESSION_NETCLIENT** ppSt_ListClient;
189187

190-
Session_Authorize_GetClient(&ppSt_ListClient, &nListCount, st_AuthProtocol.tszUserName);
191-
for (int i = 0; i < nListCount; i++)
188+
Session_Authorize_GetClient(&ppSt_ListClient, &nListCount, st_AuthProtocol.tszUserName);
189+
for (int i = 0; i < nListCount; i++)
190+
{
191+
//找到客户端,支持的模式
192+
if (0 == st_AuthConfig.st_XLogin.nMultiMode)
192193
{
193-
//找到客户端,支持的模式
194-
if (0 == st_AuthConfig.st_XLogin.nMultiMode)
195-
{
196-
int nSourceType = 0;
197-
int nDestType = 0;
198-
AuthHelp_MultiLogin_GetRange(ppSt_ListClient[i]->st_UserTable.enDeviceType, &nSourceType);
199-
AuthHelp_MultiLogin_GetRange(st_AuthProtocol.enDeviceType, &nDestType);
194+
int nSourceType = 0;
195+
int nDestType = 0;
196+
AuthHelp_MultiLogin_GetRange(ppSt_ListClient[i]->st_UserTable.enDeviceType, &nSourceType);
197+
AuthHelp_MultiLogin_GetRange(st_AuthProtocol.enDeviceType, &nDestType);
200198

201-
if (nSourceType == nDestType)
202-
{
203-
bLogin = true;
204-
break;
205-
}
206-
}
207-
else if (1 == st_AuthConfig.st_XLogin.nMultiMode)
208-
{
209-
if (ppSt_ListClient[i]->st_UserTable.enDeviceType == st_AuthProtocol.enDeviceType)
210-
{
211-
bLogin = true;
212-
break;
213-
}
214-
}
215-
else if (2 == st_AuthConfig.st_XLogin.nMultiMode)
199+
if (nSourceType == nDestType)
216200
{
201+
bLogin = true;
217202
break;
218203
}
219-
else
204+
}
205+
else if (1 == st_AuthConfig.st_XLogin.nMultiMode)
206+
{
207+
if (ppSt_ListClient[i]->st_UserTable.enDeviceType == st_AuthProtocol.enDeviceType)
220208
{
221-
pSt_ProtocolHdr->wReserve = 257;
222-
Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType);
223-
XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
224-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,登录失败,服务端设置不正确"), lpszClientAddr, st_AuthProtocol.tszUserName);
225-
return false;
209+
bLogin = true;
210+
break;
226211
}
227212
}
228-
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClient, nListCount);
229-
//对多端登录的类型进行验证
213+
else if (2 == st_AuthConfig.st_XLogin.nMultiMode)
214+
{
215+
break;
216+
}
217+
else
218+
{
219+
pSt_ProtocolHdr->wReserve = 257;
220+
Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType);
221+
XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
222+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,登录失败,服务端设置不正确"), lpszClientAddr, st_AuthProtocol.tszUserName);
223+
return false;
224+
}
225+
}
226+
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClient, nListCount);
227+
//对多端登录的类型进行验证
228+
if (bLogin && st_FunSwitch.bSwitchMulti)
229+
{
230230
if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_SECOND == st_UserTable.enSerialType)
231231
{
232-
if (!st_AuthConfig.st_XLogin.st_MulitLogin.bSecond)
232+
if (st_AuthConfig.st_XLogin.st_MulitLogin.bSecond)
233233
{
234-
bLogin = true;
234+
bLogin = false;
235235
}
236236
}
237237
else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_TIME == st_UserTable.enSerialType)
238238
{
239-
if (!st_AuthConfig.st_XLogin.st_MulitLogin.bTime)
239+
if (st_AuthConfig.st_XLogin.st_MulitLogin.bTime)
240240
{
241-
bLogin = true;
241+
bLogin = false;
242242
}
243243
}
244244
else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_DAY == st_UserTable.enSerialType)
245245
{
246-
if (!st_AuthConfig.st_XLogin.st_MulitLogin.bDay)
246+
if (st_AuthConfig.st_XLogin.st_MulitLogin.bDay)
247247
{
248-
bLogin = true;
248+
bLogin = false;
249249
}
250250
}
251251
else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_CUSTOM == st_UserTable.enSerialType)
252252
{
253-
if (!st_AuthConfig.st_XLogin.st_MulitLogin.bCustom)
253+
if (st_AuthConfig.st_XLogin.st_MulitLogin.bCustom)
254254
{
255-
bLogin = true;
255+
bLogin = false;
256256
}
257257
}
258258
else
259259
{
260260
bLogin = true; //其他注册类型禁止登录
261261
}
262-
//判断这次登录是否允许
263-
if (bLogin)
264-
{
265-
pSt_ProtocolHdr->wReserve = 253;
266-
Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType);
267-
XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
268-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,多端登录失败,用户已经登录,类型:%d"), lpszClientAddr, st_AuthProtocol.tszUserName, st_AuthProtocol.enDeviceType);
269-
return false;
270-
}
271262
}
272-
else
263+
//判断这次登录是否允许
264+
if (bLogin)
273265
{
274-
int nListCount = 0;
275-
AUTHSESSION_NETCLIENT** ppSt_ListClient;
276-
if (Session_Authorize_GetClient(&ppSt_ListClient, &nListCount, st_AuthProtocol.tszUserName))
277-
{
278-
pSt_ProtocolHdr->wReserve = 253;
279-
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClient, nListCount);
280-
Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType);
281-
XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
282-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,登录失败,用户名已经登录"), lpszClientAddr, st_AuthProtocol.tszUserName);
283-
return false;
284-
}
266+
pSt_ProtocolHdr->wReserve = 253;
267+
Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType);
268+
XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
269+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,多端登录失败,用户已经登录,类型:%d"), lpszClientAddr, st_AuthProtocol.tszUserName, st_AuthProtocol.enDeviceType);
270+
return false;
285271
}
286272
//是否被封禁
287273
if (-1 == st_UserTable.st_UserInfo.nUserLevel)

0 commit comments

Comments
 (0)