本文整理汇总了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));
}
}