void NFCDBNet_ServerModule::OnCreateRoleGameProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { NFGUID nClientID; NFMsg::ReqCreateRole xMsg; if (!m_pNetModule->ReceivePB(nMsgID, msg, nLen, xMsg, nClientID)) { return; } const std::string& strAccount = xMsg.account(); const std::string& strName = xMsg.noob_name(); NFGUID xID = m_pKernelModule->CreateGUID(); if (m_pPlayerRedisModule->CreateRole(strAccount, strName, xID)) { NFMsg::AckRoleLiteInfoList xAckRoleLiteInfoList; xAckRoleLiteInfoList.set_account(strAccount); NFMsg::RoleLiteInfo* pData = xAckRoleLiteInfoList.add_char_data(); pData->mutable_id()->CopyFrom(NFINetModule::NFToPB(xID)); pData->set_career(xMsg.career()); pData->set_game_id(pPluginManager->GetAppID()); pData->set_sex(xMsg.sex()); pData->set_race(xMsg.race()); pData->set_noob_name(xMsg.noob_name()); pData->set_role_level(1); pData->set_delete_time(0); pData->set_reg_time(0); pData->set_last_offline_time(0); pData->set_last_offline_ip(0); pData->set_view_record(""); m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_ROLE_LIST, xAckRoleLiteInfoList, nSockIndex, nClientID); } }
void NFDBNet_ServerModule::OnDeleteRoleGameProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { NFGUID nClientID; NFMsg::ReqDeleteRole xMsg; if (!m_pNetModule->ReceivePB(nMsgID, msg, nLen, xMsg, nClientID)) { return; } NFMsg::AckRoleLiteInfoList xAckRoleLiteInfoList; xAckRoleLiteInfoList.set_account(xMsg.account()); m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_ROLE_LIST, xAckRoleLiteInfoList, nSockIndex, nClientID); }
//--------------------------------------------收消息------------------------------------------------------------- void NFCPlayerLogic::OnRoleList(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::AckRoleLiteInfoList xMsg; if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } // 目前服务器只有一个角色 m_RoleList.clear(); for(int i = 0; i < xMsg.char_data_size(); i++) { m_RoleList.push_back(xMsg.char_data(i)); } DoEvent(E_PlayerEvent_RoleList, NFDataList()); }
void NFCCreateRoleModule::OnReqiureRoleListProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { NFGUID nClientID; NFMsg::ReqRoleList xMsg; if (!m_pNetModule->ReceivePB( nMsgID, msg, nLen, xMsg, nClientID)) { return; } NFGUID xPlayerID; std::string strRoleName; if (!m_pAccountRedisModule->GetRoleInfo(xMsg.account(), strRoleName, xPlayerID)) { NFMsg::AckRoleLiteInfoList xAckRoleLiteInfoList; m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_ROLE_LIST, xAckRoleLiteInfoList, nSockIndex, nClientID); return; } //NF_SHARE_PTR<NFIPropertyManager> xPlayerProperty = m_pPlayerRedisModule->LoadPlayerCacheProperty(xPlayerID); //if (xPlayerProperty) { NFMsg::AckRoleLiteInfoList xAckRoleLiteInfoList; NFMsg::RoleLiteInfo* pData = xAckRoleLiteInfoList.add_char_data(); pData->mutable_id()->CopyFrom(NFINetModule::NFToPB(xPlayerID)); pData->set_game_id(pPluginManager->GetAppID()); pData->set_career(0); pData->set_sex(0); pData->set_race(0); pData->set_noob_name(strRoleName); pData->set_role_level(0); pData->set_delete_time(0); pData->set_reg_time(0); pData->set_last_offline_time(0); pData->set_last_offline_ip(0); pData->set_view_record(""); m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_ROLE_LIST, xAckRoleLiteInfoList, nSockIndex, nClientID); } //else //{ // NFMsg::AckRoleLiteInfoList xAckRoleLiteInfoList; // m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_ROLE_LIST, xAckRoleLiteInfoList, nSockIndex, nClientID); //} }