bool NFCLoginNet_HttpServerModule::OnWorldView(const NFHttpRequest & req) { std::string strResponse; NFResponseWorldList xResponsetWorldList; NFMapEx<int, NFMsg::ServerInfoReport>& xWorldMap = m_pLoginToMasterModule->GetWorldMap(); NFMsg::ServerInfoReport* pWorldData = xWorldMap.FirstNude(); while (pWorldData) { NFResponseWorldList::NFWorld xWorld; xWorld.id = pWorldData->server_id(); xWorld.name = pWorldData->server_name(); xWorld.state = pWorldData->server_state(); xWorld.count = pWorldData->server_cur_count(); xResponsetWorldList.world.push_back(xWorld); pWorldData = xWorldMap.NextNude(); } ajson::string_stream ss; ajson::save_to(ss, xResponsetWorldList); strResponse = ss.str(); return m_pHttpNetModule->ResponseMsg(req, strResponse, NFWebStatus::WEB_OK); }
void NFCLoginNet_ServerModule::SynWorldToClient( const int nFD ) { NFMsg::AckServerList xData; xData.set_type(NFMsg::RSLT_WORLD_SERVER); NFMapEx<int, NFMsg::ServerInfoReport>& xWorldMap = m_pLoginToMasterModule->GetWorldMap(); NFMsg::ServerInfoReport* pWorldData = xWorldMap.FirstNude(); while (pWorldData) { NFMsg::ServerInfo* pServerInfo = xData.add_info(); pServerInfo->set_name(pWorldData->server_name()); pServerInfo->set_status(pWorldData->server_state()); pServerInfo->set_server_id(pWorldData->server_id()); pServerInfo->set_wait_count(0); pWorldData = xWorldMap.NextNude(); } SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_WORLD_LIST, xData, nFD); }