bool CProConsoleHandle::CheckMessage()
{
	if(m_pPacketParse->GetMessageHead() != NULL && m_pPacketParse->GetMessageBody() != NULL)
	{
		m_u4AllRecvSize += (uint32)m_pPacketParse->GetMessageHead()->length() + (uint32)m_pPacketParse->GetMessageBody()->length();
		m_u4AllRecvCount++;

		//发送回复信息
		IBuffPacket* pBuffPacket = App_BuffPacketManager::instance()->Create();

		//将数据Buff放入消息体中,传递给处理类。
		uint32 u4Return = (uint32)m_ConsoleMessage.Dispose(m_pPacketParse->GetMessageBody(), pBuffPacket);

		if(CONSOLE_MESSAGE_SUCCESS == u4Return)
		{
			if(pBuffPacket->GetPacketLen() > 0)
			{
				SendMessage((IBuffPacket* )pBuffPacket);
			}
		}

		SAFE_DELETE(m_pPacketParse);
	}
	else
	{
		OUR_DEBUG((LM_ERROR, "[CProConsoleHandle::CheckMessage] ConnectID = %d, m_pPacketParse is NULL.\n", GetConnectID()));
	}

	return true;
}
예제 #2
0
void CLSServerManager::Send_LG_Login()
{
	if(NULL == m_pServerObject)
	{
		return;
	}

	//拼装向LS注册的数据包
	uint32 u4SendPacketLen = 2 * sizeof(uint32) + 2 * sizeof(uint8) 
		+ ACE_OS::strlen(m_szLGIP) + ACE_OS::strlen(m_objlistManager.Get_MD5_Data()) + 2;

	IBuffPacket* pSendPacket = m_pServerObject->GetPacketManager()->Create();
	(*pSendPacket) << (uint16)SERVER_PROTOCAL_VERSION;
	(*pSendPacket) << (uint16)COMMAND_LOGIC_LG_LOGIN;
	(*pSendPacket) << (uint32)u4SendPacketLen;
	pSendPacket->WriteStream(m_szSessionKey, 32);

	_VCHARS_STR strLDIP;
	uint8 u1Len = (uint8)ACE_OS::strlen(m_szLGIP);
	strLDIP.SetData(m_szLGIP, u1Len);
	_VCHARS_STR strServerCode;
	u1Len = (uint8)ACE_OS::strlen(m_objlistManager.Get_MD5_Data());
	strServerCode.SetData(m_objlistManager.Get_MD5_Data(), u1Len);
	(*pSendPacket) << m_u4LGID;
	(*pSendPacket) << strLDIP;
	(*pSendPacket) << m_u4LGPort;
	(*pSendPacket) << strServerCode;

	m_pServerObject->GetClientManager()->SendData(m_u4ServerID, pSendPacket->GetData(), pSendPacket->GetPacketLen(), false);

	m_pServerObject->GetPacketManager()->Delete(pSendPacket);
}
예제 #3
0
void CBaseCommand::Do_PlugA_DATA(IMessage* pMessage)
{
	uint32     u4PacketLen  = 0;
	uint16     u2CommandID  = 0;
	VCHARM_STR strUserText;

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);
	(*pBodyPacket) >> strUserText;

	//获得数据,并交给PlugB插件去处理
	IBuffPacket* pModuleSendBuff = m_pServerObject->GetPacketManager()->Create();
	IBuffPacket* pModuleRecvBuff = m_pServerObject->GetPacketManager()->Create();

	(*pModuleSendBuff) << pMessage->GetMessageBase()->m_u4WorkThreadID;
	(*pModuleSendBuff) << pMessage->GetMessageBase()->m_u4ConnectID;
	(*pModuleSendBuff) << strUserText;

	//向PlugB通知数据处理
	m_pServerObject->GetModuleMessageManager()->SendModuleMessage("PlugB模块", MODULE_COMMAND_PLUGB, pModuleSendBuff, pModuleRecvBuff);

	uint32 u4Ret = 0;
	(*pModuleRecvBuff) >> u4Ret;

	m_pServerObject->GetPacketManager()->Delete(pModuleSendBuff);
	m_pServerObject->GetPacketManager()->Delete(pModuleRecvBuff);

	//回收收到的数据包
	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	//uint16 u2PostCommandID = COMMAND_RETURN_PLUGA;

	//返回结果
	//(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
	(*pResponsesPacket) << (uint32)u4Ret;

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_JAMPNOMAL, (uint16)COMMAND_RETURN_PLUGA, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
	}

}
예제 #4
0
bool CBaseCommand::Do_SleepWorkThread(IMessage* pMessage)
{
	uint32     u4PacketLen  = 0;
	uint16     u2CommandID  = 0;
	uint32     u4Index      = 0;

	//OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] CommandID = %d", COMMAND_BASE));

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return false;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> u2CommandID;
	(*pBodyPacket) >> u4Index;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	m_pServerObject->GetLogManager()->WriteLog(LOG_SYSTEM, "[Do_SleepWorkThread]LogData nIdex=%d.", u4Index);

	//如果是第一个包,沉睡10秒
	if(u4Index == 0)
	{
		//沉睡10秒
		ACE_Time_Value tvSleep(10, 0);
		ACE_OS::sleep(tvSleep);
	}

	
	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_AUTOTEST_RETURN_WORKTIMEOUT;

	(*pResponsesPacket) << u2PostCommandID;
	(*pResponsesPacket) << (uint32)0;

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
	}
	return true;
}
예제 #5
0
bool CBaseCommand::Do_HeadBuff(IMessage* pMessage)
{
	uint32     u4PacketLen  = 0;
	uint16     u2CommandID  = 0;
	uint64     u8ClientTime = 0;

	//OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] CommandID = %d", COMMAND_BASE));

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return false;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> u2CommandID;
	(*pBodyPacket) >> u8ClientTime;

	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_AUTOTEST_RETUEN_HEADBUFF;

	(*pResponsesPacket) << u2PostCommandID;
	(*pResponsesPacket) << u8ClientTime;

	IBuffPacket* pResponsesPacket1 = m_pServerObject->GetPacketManager()->Create();

	(*pResponsesPacket1) << u2PostCommandID;
	(*pResponsesPacket1) << u8ClientTime;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_CACHE, PACKET_IS_FRAMEWORK_RECYC);

		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket1, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket1);
	}

	return true;
}
예제 #6
0
파일: BaseCommand.cpp 프로젝트: ACEZLY/PSS
void CBaseCommand::Do_Ftp_Login( IMessage* pMessage )
{
	VCHARS_STR strUserName;
	VCHARS_STR strUserPass;

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> strUserName;
	(*pBodyPacket) >> strUserPass;

	//将接收数据转换为字符串

	//这里可以添加用户自己的逻辑判定方法
	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_RETURN_LOGIN;

	//用户密码验证
	uint32 u4Ret = CheckFtpUser(strUserName.text, strUserPass.text, pMessage->GetMessageBase()->m_u4ConnectID);

	//返回验证结果
	(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
	(*pResponsesPacket) << (uint32)u4Ret;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
	}
}
예제 #7
0
파일: BaseCommand.cpp 프로젝트: ACEZLY/PSS
void CBaseCommand::Do_Ftp_Logout( IMessage* pMessage )
{
	VCHARS_STR strUserName;

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> strUserName;

	//这里可以添加用户自己的逻辑判定方法
	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_RETURN_LOGOUT;

	//设置用户离开
	LeaveFtpUser(strUserName.text);

	//返回验证结果
	(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
	(*pResponsesPacket) << (uint32)LOGIN_SUCCESS;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, true, true);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
	}
}
예제 #8
0
bool CConsoleHandler::CheckMessage()
{
	m_u4AllRecvSize += (uint32)m_pPacketParse->GetMessageHead()->length() + (uint32)m_pPacketParse->GetMessageBody()->length();
	m_u4AllRecvCount++;
	//发送回复信息
	IBuffPacket* pBuffPacket = App_BuffPacketManager::instance()->Create();
	//将数据Buff放入消息体中
	//将数据Buff放入消息体中,传递给处理类。
	uint32 u4Return = (uint32)m_ConsoleMessage.Dispose(m_pPacketParse->GetMessageBody(), pBuffPacket);

	if (CONSOLE_MESSAGE_SUCCESS == u4Return)
	{
		if (pBuffPacket->GetPacketLen() > 0)
		{
			SendMessage((IBuffPacket*)pBuffPacket);
		}
	}

	SAFE_DELETE(m_pPacketParse);
	return true;
}
예제 #9
0
int CBaseCommand::Do_Logic_Client_Login(IMessage* pMessage)
{
	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return -1;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	_VCHARS_STR strUserName;
	_VCHARS_STR strUserPass;
	_VCHARS_STR strLSKey;

	(*pBodyPacket) >> strUserName;
	(*pBodyPacket) >> strUserPass;
	(*pBodyPacket) >> strLSKey;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	uint8  u1Type = 0;  //1需要去LS更新列表,0不需要更新
	if(ACE_OS::strcmp(strLSKey.text, m_objLSServer.Get_LS_Key()) != 0)
	{
		u1Type = 1;
	}

	//发送客户端数据
	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_LOGIC_CLIENAT_LOGIN_R;

	//设置数据报文采用网络字序
	pResponsesPacket->SetNetSort(true);

	uint32 u4UserID = 0;
	_VCHARS_STR strServerCode;

	//拼接服务器MD5
	uint8 u1Len = (uint8)ACE_OS::strlen( m_objLSServer.Get_LS_Key());
	strServerCode.SetData( m_objLSServer.Get_LS_Key(), u1Len);

	uint32 u4ListCount       = 0;
	IBuffPacket* pListPacket = NULL;
	//拼接列表包体
	if(u1Type == 1)
	{
		pListPacket = m_pServerObject->GetPacketManager()->Create();
		pListPacket->SetNetSort(true);
		m_objLSServer.Get_All_LG_List(pListPacket, u4ListCount);
	}
	
	//消息列表返回
	uint32 u4SendPacketLen = 0;
	if(u1Type == 1)
	{
		u4SendPacketLen = sizeof(uint32) + sizeof(uint8) + 
			sizeof(uint8) + ACE_OS::strlen( m_objLSServer.Get_LS_Key()) + 1
			+ sizeof(uint32) + pListPacket->GetPacketLen();
	}
	else
	{
		u4SendPacketLen = sizeof(uint32) + sizeof(uint8) + 
			sizeof(uint8) + ACE_OS::strlen( m_objLSServer.Get_LS_Key()) + 1;
	}
	(*pResponsesPacket) << pMessage->GetPacketHeadInfo()->m_u2Version;
	(*pResponsesPacket) << u2PostCommandID;
	(*pResponsesPacket) << u4SendPacketLen; //数据包体长度
	pResponsesPacket->WriteStream(pMessage->GetPacketHeadInfo()->m_szSession, SESSION_LEN);

	(*pResponsesPacket) << u4UserID;
	(*pResponsesPacket) << u1Type;
	(*pResponsesPacket) << strServerCode;

	//如果需要发送最新List列表,则在这里拼包
	if(u1Type == 1)
	{
		(*pResponsesPacket) << u4ListCount;
		pResponsesPacket->WriteStream(pListPacket->GetData(), pListPacket->GetPacketLen());
		m_pServerObject->GetPacketManager()->Delete(pListPacket);
	}

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, 
			pResponsesPacket, 
			SENDMESSAGE_JAMPNOMAL, 
			u2PostCommandID, 
			PACKET_SEND_IMMEDIATLY, 
			PACKET_IS_FRAMEWORK_RECYC);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
	}

	//m_pServerObject->GetConnectManager()->CloseConnect(pMessage->GetMessageBase()->m_u4ConnectID);

	return 0;
}
예제 #10
0
int CBaseCommand::DoMessage(IMessage* pMessage, bool& bDeleteFlag)
{	
	if(m_pServerObject == NULL)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] m_pServerObject is NULL.\n"));
		return -1;
	}

	if(pMessage == NULL)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pMessage is NULL.\n"));
		return -1;
	}

	//处理链接建立信息
	if(pMessage->GetMessageBase()->m_u2Cmd == CLIENT_LINK_CONNECT)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] CLIENT_LINK_CONNECT OK.\n"));
	}

	//处理链接断开信息
	if(pMessage->GetMessageBase()->m_u2Cmd == CLIENT_LINK_CDISCONNET)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] CLIENT_LINK_CDISCONNET OK.\n"));
	}

	//处理正常信息
	if(pMessage->GetMessageBase()->m_u2Cmd == COMMAND_BASE)
	{
		uint32     u4PacketLen = 0;
		uint16     u2CommandID = 0;
		VCHARS_STR strsName;
		string     strName;

		IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
		if(NULL == pBodyPacket)
		{
			OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
			return -1;
		}
		
		_PacketInfo BodyPacket;
		pMessage->GetPacketBody(BodyPacket);

		pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

		(*pBodyPacket) >> u2CommandID;
		(*pBodyPacket) >> strsName;
		strName.assign(strsName.text, strsName.u1Len);

		m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

		//ACE_Time_Value tvSleep(10);
		//ACE_OS::sleep(tvSleep);

		if(NULL != m_pServerObject->GetLogManager())
		{
			m_pServerObject->GetLogManager()->WriteLog(LOG_SYSTEM,  "[CBaseCommand::DoMessage] Get CommandID = %d", u2CommandID);
		}
		else
		{
			OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pLogManager = NULL"));
		}

		//测试返回数据(UDP)
		if(NULL != m_pServerObject->GetUDPConnectManager())
		{
			char* pReturn = new char[MAX_BUFF_100];
			sprintf_safe(pReturn, MAX_BUFF_100, "Hello friend.");
			m_pServerObject->GetUDPConnectManager()->SendMessage(0, pReturn, (uint32)ACE_OS::strlen(pReturn), pMessage->GetMessageBase()->m_szIP, pMessage->GetMessageBase()->m_u4Port);
		}
	}
예제 #11
0
int CBaseCommand::DoMessage(IMessage* pMessage, bool& bDeleteFlag)
{	
	if(m_pServerObject == NULL)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] m_pServerObject is NULL.\n"));
		return -1;
	}

	if(pMessage == NULL)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pMessage is NULL.\n"));
		return -1;
	}

	if(pMessage->GetMessageBase()->m_u2Cmd == CLIENT_LINK_CDISCONNET)
	{
		mapLoginUserInfo::iterator f = m_mapLoginUserInfo.find(pMessage->GetMessageBase()->m_u4ConnectID);
		if(f != m_mapLoginUserInfo.end())
		{
			//用户链接断开,清理用户登录信息
			_LoginUserInfo objLoginUserInfo = (_LoginUserInfo)f->second;

			//发送给游戏模块用户退出成功信息
			IBuffPacket* pModuleBuffPacket = m_pServerObject->GetPacketManager()->Create();
			(*pModuleBuffPacket) << (uint32)objLoginUserInfo.m_u4PlayerID;
			(*pModuleBuffPacket) << (uint32)pMessage->GetMessageBase()->m_u4ConnectID;
			m_pServerObject->GetModuleMessageManager()->SendModuleMessage("DKPoker-GameCenter", COMMAND_MODULE_LOGOUT, pModuleBuffPacket, NULL);

			m_mapLoginUserInfo.erase(f);

			//这里清理临时变量
			m_pServerObject->GetPacketManager()->Delete(pModuleBuffPacket);
		}
	}
	//处理用户登录信息
	else if(pMessage->GetMessageBase()->m_u2Cmd == COMMAND_USERIN)
	{
		uint16     u2CommandID  = 0;
		VCHARS_STR strUserName;
		char       szPlayerNick[MAX_BUFF_20] = {'\0'};
		
		//OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] CommandID = %d", COMMAND_BASE));
		
		IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
		if(NULL == pBodyPacket)
		{
			OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
			return -1;
		}
		
		_PacketInfo BodyPacket;
		pMessage->GetPacketBody(BodyPacket);

		pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

		(*pBodyPacket) >> u2CommandID;
		(*pBodyPacket) >> strUserName;
		
		//这里调用处理逻辑
		if(strUserName.u1Len >= MAX_BUFF_20)
		{
			strUserName.u1Len = MAX_BUFF_20;
		}
		ACE_OS::memcpy(szPlayerNick, strUserName.text, strUserName.u1Len);
		int32 n4Pos = m_objSMDataManager.ReadPlayerSMPos(szPlayerNick);

		_UserPlayer* pUserPlayer = m_objSMDataManager.GetUserPlayer(n4Pos);

		//返回数据(TCP)
		if(NULL != pUserPlayer)
		{
			//如果登录成功,则添加到对应的表中
			mapLoginUserInfo::iterator f = m_mapLoginUserInfo.find(pMessage->GetMessageBase()->m_u4ConnectID);
			if(f == m_mapLoginUserInfo.end())
			{
				_LoginUserInfo objLoginUserInfo;
				objLoginUserInfo.m_u4PlayerID = pUserPlayer->m_u4PlayerID;
				sprintf_safe(objLoginUserInfo.m_szPlayerNick, MAX_BUFF_20, "%s", szPlayerNick);
				m_mapLoginUserInfo.insert(mapLoginUserInfo::value_type(pMessage->GetMessageBase()->m_u4ConnectID, objLoginUserInfo));
			}

			//发送给游戏模块用户登录成功信息
			IBuffPacket* pModuleBuffPacket = m_pServerObject->GetPacketManager()->Create();
			(*pModuleBuffPacket) << (uint32)n4Pos;
			(*pModuleBuffPacket) << (uint32)pUserPlayer->m_u4PlayerID;
			(*pModuleBuffPacket) << (uint32)pMessage->GetMessageBase()->m_u4ConnectID;
			m_pServerObject->GetModuleMessageManager()->SendModuleMessage("DKPoker-GameCenter", COMMAND_MODULE_LOGIN, pModuleBuffPacket, NULL);

			//这里清理临时变量
			m_pServerObject->GetPacketManager()->Delete(pBodyPacket);
			m_pServerObject->GetPacketManager()->Delete(pModuleBuffPacket);


			IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
			uint16 u2PostCommandID = COMMAND_RETURN_USERIN;
			(*pResponsesPacket) << u2PostCommandID;
			(*pResponsesPacket) << pUserPlayer->m_u4PlayerID;
			if(NULL != m_pServerObject->GetConnectManager())
			{
				//发送数据
				m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, true);
			}
			else
			{
				OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
			}
		}
		else
		{
			IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
			uint16 u2PostCommandID = COMMAND_RETURN_USERIN;
			(*pResponsesPacket) << u2PostCommandID;
			(*pResponsesPacket) << (uint32)PLAYER_INVALID_ID;
			if(NULL != m_pServerObject->GetConnectManager())
			{
				//发送数据
				m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, true);
			}
			else
			{
				OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
			}
		}
	}
예제 #12
0
파일: BaseCommand.cpp 프로젝트: ACEZLY/PSS
void CBaseCommand::Do_Ftp_FileUpLoad(IMessage* pMessage)
{
	VCHARS_STR strUserName;
	VCHARM_STR strFilePath;
	VCHARB_STR strFileBuffer(false, VCHARS_TYPE_BINARY);          //文件块信息(二进制模式)
	uint32     u4BlockSize;            //块大小
	uint32     u4CurrBlockIndex;       //当前块ID

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> strUserName;
	(*pBodyPacket) >> strFilePath;
	(*pBodyPacket) >> u4BlockSize;
	(*pBodyPacket) >> u4CurrBlockIndex;
	(*pBodyPacket) >> strFileBuffer;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	bool blState = CheckOnlineUser(strUserName.text, pMessage->GetMessageBase()->m_u4ConnectID);
	if(blState == true)
	{
		//获得文件块
		CDirView objDirView;
		uint32 u4BufferCount = 0;
		objDirView.GetFileBufferCount(strFilePath.text, u4BlockSize, u4BufferCount);
		if(u4CurrBlockIndex > u4BufferCount)
		{
			return;
		}

		char* pBuffer = new char[u4BlockSize];

		//接收文件块信息
		ACE_OS::memcpy(pBuffer, strFileBuffer.text, strFileBuffer.u4Len);
		bool blRet = objDirView.SetFileBuffer(strFilePath.text, pBuffer, u4BlockSize, u4CurrBlockIndex);
		if(blRet == true)
		{
			//组成发送包
			IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
			uint16 u2PostCommandID = COMMAND_RETURN_FILE_UPLOAD;

			(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
			(*pResponsesPacket) << (uint32)OP_OK;

			if(NULL != m_pServerObject->GetConnectManager())
			{
				//发送全部数据
				m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
			}
			else
			{
				OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
				m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
			}
		}

		SAFE_DELETE_ARRAY(pBuffer);
	}
	else
	{
		IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
		uint16 u2PostCommandID = COMMAND_RETURN_FILE_UPLOAD;

		(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
		(*pResponsesPacket) << (uint32)OP_FAIL;

		if(NULL != m_pServerObject->GetConnectManager())
		{
			//发送全部数据
			m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
		}
		else
		{
			OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
			m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
		}
	}
}
예제 #13
0
파일: BaseCommand.cpp 프로젝트: ACEZLY/PSS
void CBaseCommand::Do_Ftp_FileList( IMessage* pMessage )
{
	VCHARS_STR strUserName;
	VCHARM_STR strFilePath;

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> strUserName;
	(*pBodyPacket) >> strFilePath;

	//这里可以添加用户自己的逻辑判定方法
	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_RETURN_FILELIST;

	//查看用户有无操作权限
	bool blState = CheckOnlineUser(strUserName.text, pMessage->GetMessageBase()->m_u4ConnectID);
	if(blState == false)
	{
		//返回验证结果
		(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
		(*pResponsesPacket) << (uint32)OP_FAIL;
	}
	else
	{
		(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
		(*pResponsesPacket) << (uint32)OP_OK;
		CDirView objDirView;

		//组织文件信息
		vevFileInfo objvevFileInfo;
		objDirView.GetDir(strFilePath.text, objvevFileInfo);
		(*pResponsesPacket) << (uint32)objvevFileInfo.size();
		VCHARS_STR strFileName;
		for(uint32 i = 0; i < (uint32)objvevFileInfo.size(); i++)
		{
			strFileName.text = (char* )objvevFileInfo[i].m_szFileName;
			strFileName.u1Len = (uint8)ACE_OS::strlen(objvevFileInfo[i].m_szFileName);
			(*pResponsesPacket) << strFileName;
			(*pResponsesPacket) << objvevFileInfo[i].m_u4FileType;
			(*pResponsesPacket) << objvevFileInfo[i].m_u4FileSize;
		}
	}


	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
	}
}
예제 #14
0
int CPlayerPoolCommand::DoMessage(IMessage* pMessage, bool& bDeleteFlag)
{
	uint16 u2CommandID = 0;
	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return -1;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> u2CommandID;

	//根据ID进行数据处理(玩家数据添加)
	if(u2CommandID == COMMAND_PLAYINSERT)
	{
		VCHARS_STR strsData;
		char szNick[20] = {'\0'};
		(*pBodyPacket) >> strsData;
		sprintf_safe(szNick, 20, "%s", strsData.text);
		szNick[strsData.u1Len] = '\0';
		CPlayerData* pData = Do_PlayerInsert(szNick);

		m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

		if(NULL != pData)
		{
			//返回数据
			IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
			VCHARM_STR strMData;
			strMData.u2Len = sizeof(CPlayerData);
			strMData.text  = (const char* )pData;

			(*pResponsesPacket) << (uint16)COMMAND_PLAYINSERT;
			(*pResponsesPacket) << (uint8)1;         //1表示有数据
			(*pResponsesPacket) << strMData;

			if(NULL != m_pServerObject->GetConnectManager())
			{
				m_pServerObject->GetConnectManager()->SendMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket);
			}
			else
			{
				OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
			}
		}
		else
		{
			//返回数据
			IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();

			(*pResponsesPacket) << (uint16)COMMAND_PLAYINSERT;
			(*pResponsesPacket) << (uint8)0;         //0表示没有数据

			if(NULL != m_pServerObject->GetConnectManager())
			{
				m_pServerObject->GetConnectManager()->SendMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket);
			}
			else
			{
				OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
			}
		}
	}
예제 #15
0
파일: BaseCommand.cpp 프로젝트: arlose/PSS
int CBaseCommand::DoMessage(IMessage* pMessage, bool& bDeleteFlag)
{
  //__ENTER_FUNCTION是自动给你的函数追加try的宏,用于捕捉错误,你可以使用__THROW_FUNCTION()抛出你的错误
  //比如__THROW_FUNCTION("hello"); 它会自动在Log文件夹下的assert.log记录文件名,函数名,行数,描述。
  //推荐你使用这个宏,记住一定要在函数的结束使用__LEAVE_FUNCTION或者__LEAVE_FUNCTION_WITHRETURN与之配对。
  //__LEAVE_FUNCTION_WITHRETURN和__LEAVE_FUNCTION不同是前者可以支持函数退出的时候返回一个变量
  //比如这个函数是返回一个int
  //那么末尾就是__LEAVE_FUNCTION_WITHRETURN(0); 0就是返回的int,当然,也支持别的类型变量,具体看你自己的函数。
  //如果函数不返回任何变量,你可以使用__LEAVE_FUNCTION即可。
  __ENTER_FUNCTION();

  if(m_pServerObject == NULL)
  {
    OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] m_pServerObject is NULL.\n"));
    return -1;
  }

  if(pMessage == NULL)
  {
    OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pMessage is NULL.\n"));
    return -1;
  }

  //处理链接建立信息
  if(pMessage->GetMessageBase()->m_u2Cmd == CLIENT_LINK_CONNECT)
  {
    OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] CLIENT_LINK_CONNECT OK.\n"));
    return 0;
  }

  //处理链接断开信息
  if(pMessage->GetMessageBase()->m_u2Cmd == CLIENT_LINK_CDISCONNET)
  {
    OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] CLIENT_LINK_CDISCONNET OK.\n"));
    return 0;
  }

  //处理正常信息
  if(pMessage->GetMessageBase()->m_u2Cmd == COMMAND_BASE)
  {
    uint32     u4PacketLen  = 0;
    uint16     u2CommandID  = 0;
    uint64     u8ClientTime = 0;

    //OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] CommandID = %d", COMMAND_BASE));

    IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
    if(NULL == pBodyPacket)
    {
      OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
      return -1;
    }

    _PacketInfo BodyPacket;
    pMessage->GetPacketBody(BodyPacket);

    pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

    //(*pBodyPacket) >> u2CommandID;
    //(*pBodyPacket) >> u8ClientTime;

	//测试记录二进制日志
	//m_pServerObject->GetLogManager()->WriteLogBinary(LOG_SYSTEM, BodyPacket.m_pData, BodyPacket.m_nDataLen);

	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_BASE;

	//数据原样奉还
    (*pResponsesPacket) << (uint32)BodyPacket.m_nDataLen;
	pResponsesPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

    //(*pResponsesPacket) << u2PostCommandID;
    //(*pResponsesPacket) << u8ClientTime;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

    if(NULL != m_pServerObject->GetConnectManager())
    {
      //发送全部数据
      m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_JAMPNOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
    }
    else
    {
      OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
	  m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
    }

  }

  return 0;

  __LEAVE_FUNCTION_WITHRETURN(0);
}