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); }
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; }