void NFDBNet_ServerModule::OnRequireRoleListProcess(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_pPlayerRedisModule->GetRoleInfo(xMsg.account(), strRoleName, xPlayerID)) { NFMsg::AckRoleLiteInfoList xAckRoleLiteInfoList; xAckRoleLiteInfoList.set_account(xMsg.account()); m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_ROLE_LIST, xAckRoleLiteInfoList, nSockIndex, nClientID); return; } NFMsg::AckRoleLiteInfoList xAckRoleLiteInfoList; xAckRoleLiteInfoList.set_account(xMsg.account()); 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); }
void NFCProxyServerNet_ServerModule::OnReqRoleListProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { //在没有正式进入游戏之前,nPlayerID都是FD NFGUID nPlayerID; NFMsg::ReqRoleList xData; if (!m_pNetModule->ReceivePB(nSockIndex, nMsgID, msg, nLen, xData, nPlayerID)) { return; } NF_SHARE_PTR<ConnectData> pServerData = m_pProxyServerToGameModule->GetClusterModule()->GetServerNetInfo(xData.game_id()); if (pServerData && ConnectDataState::NORMAL == pServerData->eState) { //数据匹配 NetObject* pNetObject = m_pNetModule->GetNet()->GetNetObject(nSockIndex); if (pNetObject && pNetObject->GetConnectKeyState() > 0 && pNetObject->GetGameID() == xData.game_id() && pNetObject->GetAccount() == xData.account()) { NFMsg::MsgBase xMsg; if (!xData.SerializeToString(xMsg.mutable_msg_data())) { return; } //playerid主要是网关转发消息的时候做识别使用,其他使用不使用 xMsg.mutable_player_id()->CopyFrom(NFINetModule::NFToPB(pNetObject->GetClientID())); std::string strMsg; if (!xMsg.SerializeToString(&strMsg)) { return; } m_pProxyServerToGameModule->GetClusterModule()->SendByServerID(pNetObject->GetGameID(), NFMsg::EGameMsgID::EGMI_REQ_ROLE_LIST, strMsg); } } }