本文整理汇总了C++中nfmsg::ServerInfoReport::mutable_server_info_list_ext方法的典型用法代码示例。如果您正苦于以下问题:C++ ServerInfoReport::mutable_server_info_list_ext方法的具体用法?C++ ServerInfoReport::mutable_server_info_list_ext怎么用?C++ ServerInfoReport::mutable_server_info_list_ext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nfmsg::ServerInfoReport
的用法示例。
在下文中一共展示了ServerInfoReport::mutable_server_info_list_ext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ServerReport
void NFCWorldToMasterModule::ServerReport()
{
if (mLastReportTime + 10 > pPluginManager->GetNowTime())
{
return;
}
mLastReportTime = pPluginManager->GetNowTime();
std::shared_ptr<NFIClass> xLogicClass = m_pClassModule->GetElement(NFrame::Server::ThisName());
if (xLogicClass)
{
NFList<std::string>& strIdList = xLogicClass->GetIdList();
std::string strId;
for (bool bRet = strIdList.First(strId); bRet; bRet = strIdList.Next(strId))
{
const int nServerType = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Type());
const int nServerID = m_pElementModule->GetPropertyInt(strId, NFrame::Server::ServerID());
if (pPluginManager->GetAppID() == nServerID)
{
const int nPort = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Port());
const int nMaxConnect = m_pElementModule->GetPropertyInt(strId, NFrame::Server::MaxOnline());
const std::string& strName = m_pElementModule->GetPropertyString(strId, NFrame::Server::Name());
const std::string& strIP = m_pElementModule->GetPropertyString(strId, NFrame::Server::IP());
NFMsg::ServerInfoReport reqMsg;
reqMsg.set_server_id(nServerID);
reqMsg.set_server_name(strName);
reqMsg.set_server_cur_count(0);
reqMsg.set_server_ip(strIP);
reqMsg.set_server_port(nPort);
reqMsg.set_server_max_online(nMaxConnect);
reqMsg.set_server_state(NFMsg::EST_NARMAL);
reqMsg.set_server_type(nServerType);
for (int n = 0;n < 10;n++)
{
AddServerInfoExt("key" + lexical_cast<std::string>(n), "value" + lexical_cast<std::string>(n));
}
NFMsg::ServerInfoExt pb_ServerInfoExt;
for (auto it = m_mServerInfoExt.begin(); it != m_mServerInfoExt.end(); it++)
{
*pb_ServerInfoExt.add_key() = it->first;
*pb_ServerInfoExt.add_value() = it->second;
}
reqMsg.mutable_server_info_list_ext()->CopyFrom(pb_ServerInfoExt);
std::shared_ptr<ConnectData> pServerData = m_pNetClientModule->GetServerList().First();
if (pServerData)
{
m_pNetClientModule->SendToServerByPB(pServerData->nGameID, NFMsg::EGMI_STS_SERVER_REPORT, reqMsg);
}
}
}
}
}
示例2: Register
void NFCWorldToMasterModule::Register(NFINet* pNet)
{
NF_SHARE_PTR<NFIClass> xLogicClass = m_pClassModule->GetElement(NFrame::Server::ThisName());
if (xLogicClass)
{
NFList<std::string>& strIdList = xLogicClass->GetIdList();
std::string strId;
for (bool bRet = strIdList.First(strId); bRet; bRet = strIdList.Next(strId))
{
const int nServerType = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Type());
const int nServerID = m_pElementModule->GetPropertyInt(strId, NFrame::Server::ServerID());
if (nServerType == NF_SERVER_TYPES::NF_ST_WORLD && pPluginManager->GetAppID() == nServerID)
{
const int nPort = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Port());
const int nMaxConnect = m_pElementModule->GetPropertyInt(strId, NFrame::Server::MaxOnline());
const int nCpus = m_pElementModule->GetPropertyInt(strId, NFrame::Server::CpuCount());
const std::string& strName = m_pElementModule->GetPropertyString(strId, NFrame::Server::Name());
const std::string& strIP = m_pElementModule->GetPropertyString(strId, NFrame::Server::IP());
NFMsg::ServerInfoReportList xMsg;
NFMsg::ServerInfoReport* pData = xMsg.add_server_list();
pData->set_server_id(nServerID);
pData->set_server_name(strName);
pData->set_server_cur_count(0);
pData->set_server_ip(strIP);
pData->set_server_port(nPort);
pData->set_server_max_online(nMaxConnect);
pData->set_server_state(NFMsg::EST_NARMAL);
pData->set_server_type(nServerType);
NFMsg::ServerInfoExt pb_ServerInfoExt;
pData->mutable_server_info_list_ext()->CopyFrom(pb_ServerInfoExt);
NF_SHARE_PTR<ConnectData> pServerData = m_pNetClientModule->GetServerNetInfo(pNet);
if (pServerData)
{
int nTargetID = pServerData->nGameID;
m_pNetClientModule->SendToServerByPB(nTargetID, NFMsg::EGameMsgID::EGMI_MTL_WORLD_REGISTERED, xMsg);
m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(0, pData->server_id()), pData->server_name(), "Register");
}
}
}
}
}