コード例 #1
0
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);
}
コード例 #2
0
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);
}