当前位置: 首页>>代码示例>>C++>>正文


C++ Subscription::set_topicid方法代码示例

本文整理汇总了C++中Subscription::set_topicid方法的典型用法代码示例。如果您正苦于以下问题:C++ Subscription::set_topicid方法的具体用法?C++ Subscription::set_topicid怎么用?C++ Subscription::set_topicid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription::set_topicid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handle_timeout

	void MulticastPoint::handle_timeout(const boost::system::error_code& error)
	{
		if (!error)
		{
			//std::cout<<"timeout"<<std::endl;
			canWarn = true; //Re enable send error warnings
			KSystem::Time::TimeAbsolute now = KSystem::Time::SystemTime::now();
			{
				//Clean old hosts first
				std::map<hostid, hostDescription>::iterator  t, hit = otherHosts.begin();
				KSystem::Time::TimeAbsolute oldest = now - KSystem::Time::TimeAbsolute::milliseconds(cleanupandbeacon * 4);

				while(hit != otherHosts.end())
				{
					if((*hit).first == Messaging::MessageEntry::HOST_ID_ANY_HOST) //Do not cleanup ANYHOST
					{
						++hit;
						continue;
					}

					if((*hit).second.lastseen < oldest)
					{
						//std::cout<<"Cleaning Host:"<<(*hit).first<<std::endl;
						t = hit++;
						otherHosts.erase(t);
					}
					else
						hit++;
				}

				cleanupLocalSubscriptions();


			}
			{
				HostSubscriptions *hs = HostSubscriptions::default_instance().New();
				hs->set_hostname(boost::asio::ip::host_name());
				std::map<hostid, hostDescription>::const_iterator hit = otherHosts.begin();

				for(; hit != otherHosts.end(); ++hit)
				{
					std::set<size_t>::const_iterator tit = (*hit).second.providesTopics.begin();

					for(; tit != (*hit).second.providesTopics.end(); ++tit)
					{
						Subscription *s = hs->add_topics();
						s->set_host((*hit).first);
						s->set_topicid(*tit);
						//std::cout<<"Requesting"<<(*hit).first<<" "<<(*tit)<<std::endl;
					}
				}

				Messaging::MessageEntry m;
				m.msg.reset(hs);
				m.topic = Messaging::Topics::Instance().getId("communication");
				m.msgclass = Messaging::MessageEntry::STATE;
				m.timestamp = now.wrapTo<KSystem::Time::TimeStamp>();
				m.host = Messaging::MessageEntry::HOST_ID_LOCAL_HOST;
				//std::cout<<"Beacon"<<std::endl;
				processOutGoing(m);
			}
			{
				//Internal message, forwarded to localhost, keeps track of known hosts, and this host info.
				KnownHosts *kn = KnownHosts::default_instance().New();
				//Who am I?
				kn->mutable_localhost()->set_hostid(thishost);
				kn->mutable_localhost()->set_hostname(boost::asio::ip::host_name());

				std::map<hostid, hostDescription>::const_iterator kit = otherHosts.begin();

				for(; kit != otherHosts.end(); ++kit)
				{
					if((*kit).first == Messaging::MessageEntry::HOST_ID_ANY_HOST) //Do not report ANYHOST
						continue;

					HostEntry *e = kn->add_entrylist();
					e->set_hostid((*kit).first);
					e->set_hostname((*kit).second.hostname);
				}

				Messaging::MessageEntry m;
				m.msg.reset(kn);
				m.topic = Messaging::Topics::Instance().getId("communication");
				m.msgclass = Messaging::MessageEntry::STATE;
				m.timestamp = now.wrapTo<KSystem::Time::TimeStamp>();
				m.host = Messaging::MessageEntry::HOST_ID_LOCAL_HOST;
				publish(m);
			}
			dep.cleanOlderThan(KSystem::Time::TimeAbsolute::milliseconds(cleanupandbeacon * 2));
			timer_.expires_from_now(boost::posix_time::milliseconds(cleanupandbeacon));
			timer_.async_wait(
			    boost::bind(&MulticastPoint::handle_timeout, this,
			                boost::asio::placeholders::error));
		}
	}
开发者ID:kouretes,项目名称:Monas,代码行数:95,代码来源:multicastpoint.cpp


注:本文中的Subscription::set_topicid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。