void CLogSocket::OnSocketConnect(void* Sender)
	{
		if ("" == m_sServiceName)
		{
			if (m_bListView)
				RegisterServerEx();
			else
				RegisterServer();
		}
		SendWaitMsg();
	}
Esempio n. 2
0
//! 响应客户端请求角色基本信息列表
VOID LoginManager::OnClientQuestPlayerBaseList(const char *pCdKey, const char *pWsName)
{
	assert(NULL != pCdKey && NULL != pWsName);
#ifdef _RUNSTACKINFO_
	BOOL bNormalClear = FALSE;
#endif
	do 
	{
		tagAccountInfo_ToAS &AccountInfo_ToAS = m_cqueuePassedAccount.find_and_get(string(pCdKey));
		if(0 == AccountInfo_ToAS._dwIp)//! IP为0,说明没有找到对象
		{
			//! 处理非法登陆
			GetGame()->KickOut(pCdKey);
#ifdef _OUT_LOGIN_FLOW_INFO_
			AddLogText("玩家[%s]请求基本角色信息时,还不存在于已通过验证的列表名单中,弹出玩家!", pCdKey);
#endif
			break;
		}

		assert(-1 == AccountInfo_ToAS._lWsID);
		LONG lWsID = GetGame()->GetWorldIDByName(pWsName);
		if(-1 == lWsID)
		{
			//! 处理非法登陆
			GetGame()->KickOut(pCdKey);
#ifdef _OUT_LOGIN_FLOW_INFO_
			AddLogText("玩家[%s]请求基本角色信息时,发送了非法的WS名字信息,弹出玩家!", pCdKey);
#endif
			break;
		}
		AccountInfo_ToAS._lWsID = lWsID;

		if(!GetGame()->WsIsReady(lWsID))
		{
			CMessage msg(MSG_L2C_LOG_ANSWER_PLAYERBASELIST);
			// 添加验证代码
			msg.Add((long)0xFFFFFFFF);
			msg.Add((BYTE)0);// flag
			msg.Add((pCdKey));// cdkey
			msg.Add((short)0);// flag
			msg.SendToClient(AccountInfo_ToAS._lSocket);
#ifdef _OUT_LOGIN_FLOW_INFO_
			AddLogText("玩家[%s]请求基本角色信息时,对应的WS还没有准备好!", pCdKey);
#endif
			break;
		}

		//! 放入WS等待队列
		if(WS_NAME_SIZE > strlen(pWsName))
			strcpy(AccountInfo_ToAS._szWSName, pWsName);
		else
		{
			//! 配置了错误的WS数据,WS名字过长
			assert(false);
			AddLogText("Server setup error!!!, World's name too long!!!");
			GetGame()->KickOut(pCdKey);
			break;
		}

		//! 如果是不排队玩家
		if(IsNotQueueCdKey(pCdKey))
		{
			if(GetGame()->EnterToSelect(
				AccountInfo_ToAS._szCdkey,
				AccountInfo_ToAS._szWSName,
				AccountInfo_ToAS._dwIp,
				AccountInfo_ToAS._lSocket))
			{
				QueueWsCanInGamePlayer &WsCanInGamePlayer = m_mapCanInGamePlayer[AccountInfo_ToAS._lWsID];
				assert(!WsCanInGamePlayer.find(string(AccountInfo_ToAS._szCdkey)));
				AccountInfo_ToAS._dwEndTime = timeGetTime() + GetGame()->GetLoginSetup()->m_SelectWaitTimeSpace;
				WsCanInGamePlayer.push_back(string(AccountInfo_ToAS._szCdkey), AccountInfo_ToAS);
			}
		}
		else
		{
			WaitInWsQueue *pWaitInWsQueue = GetWaitInWsQueue(AccountInfo_ToAS._lWsID);
			if(NULL == pWaitInWsQueue)
			{
				//! 非法登陆、WS不存在
				GetGame()->KickOut(pCdKey);
#ifdef _OUT_LOGIN_FLOW_INFO_
				AddLogText("玩家[%s]请求基本角色信息时,没有找到所请求的WS,属于非法消息,弹出玩家!", pCdKey);
#endif
			}
			else
			{
				pWaitInWsQueue->push_back(string(pCdKey), AccountInfo_ToAS);
#ifdef _OUT_LOGIN_FLOW_INFO_
				bNormalClear = TRUE;
#endif
				//! 发送第一次排队信息
				LONG uPlayerOrder = pWaitInWsQueue->size();
				DWORD dwWsCurrNum = GetGame()->GetLoginWorldPlayerNumByWorldID(AccountInfo_ToAS._lWsID);
				dwWsCurrNum += m_mapCanInGamePlayer[AccountInfo_ToAS._lWsID].size();
				if(1 < uPlayerOrder || m_dwMaxWsMum <= dwWsCurrNum)
					SendWaitMsg(AccountInfo_ToAS, &uPlayerOrder);
			}
		}
	} 
	while(false);

#ifdef _OUT_LOGIN_FLOW_INFO_
	if(bNormalClear)
	{
		AddLogText("玩家[%s]发送基本角色信息,正常清除CD-KEY!", pCdKey);
	}
#endif
	m_cqueuePassedAccount.erase(string(pCdKey));
}