本文整理汇总了C++中TopicPrx::getSubscribers方法的典型用法代码示例。如果您正苦于以下问题:C++ TopicPrx::getSubscribers方法的具体用法?C++ TopicPrx::getSubscribers怎么用?C++ TopicPrx::getSubscribers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopicPrx
的用法示例。
在下文中一共展示了TopicPrx::getSubscribers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: error
void
Parser::subscribers(const list<string>& args)
{
if(args.empty())
{
error("subscribers' requires at least one argument (type `help' for more info) ");
return;
}
try
{
for(list<string>::const_iterator i = args.begin(); i != args.end() ; ++i)
{
TopicPrx topic = _defaultManager->retrieve(*i);
cout << (*i) << ": subscribers:" << endl;
IdentitySeq subscribers = topic->getSubscribers();
for(IdentitySeq::const_iterator j = subscribers.begin(); j != subscribers.end(); ++j)
{
cout << "\t" << _communicator->identityToString(*j) << endl;
}
}
}
catch(const Exception& ex)
{
exception(ex);
}
}
示例2: test
//.........这里部分代码省略.........
}
catch(const IceStorm::NoSuchTopic& e)
{
cerr << argv[0] << ": NoSuchTopic: " << e.name << endl;
return EXIT_FAILURE;
}
//
// Test subscriber identity that is too long
//
if(string(argv[1]) != "transient")
{
try
{
Ice::ObjectPrx object = communicator->stringToProxy(string(512, 'A') + ":default -p 10000");
topic->subscribeAndGetPublisher(IceStorm::QoS(), object);
test(false);
}
catch(const Ice::UnknownException&)
{
}
}
//
// Create subscribers with different QoS.
//
vector<SingleIPtr> subscribers;
vector<Ice::Identity> subscriberIdentities;
{
subscribers.push_back(new SingleI(communicator, "default"));
Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back())->ice_oneway();
subscriberIdentities.push_back(object->ice_getIdentity());
topic->subscribeAndGetPublisher(IceStorm::QoS(), object);
}
{
subscribers.push_back(new SingleI(communicator, "oneway"));
Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back())->ice_oneway();
subscriberIdentities.push_back(object->ice_getIdentity());
topic->subscribeAndGetPublisher(IceStorm::QoS(), object);
}
{
subscribers.push_back(new SingleI(communicator, "twoway"));
Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back());
subscriberIdentities.push_back(object->ice_getIdentity());
topic->subscribeAndGetPublisher(IceStorm::QoS(), object);
}
{
subscribers.push_back(new SingleI(communicator, "batch"));
Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back())->ice_batchOneway();
subscriberIdentities.push_back(object->ice_getIdentity());
topic->subscribeAndGetPublisher(IceStorm::QoS(), object);
}
{
subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered
IceStorm::QoS qos;
qos["reliability"] = "ordered";
Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back());
subscriberIdentities.push_back(object->ice_getIdentity());
topic->subscribeAndGetPublisher(qos, object);
}
{
// Use a separate adapter to ensure a separate connection is used for the subscriber
// (otherwise, if multiple UDP subscribers use the same connection we might get high
// packet loss, see bug 1784).
ObjectAdapterPtr adpt = communicator->createObjectAdapterWithEndpoints("UdpAdapter3", "udp");
subscribers.push_back(new SingleI(communicator, "datagram"));
Ice::ObjectPrx object = adpt->addWithUUID(subscribers.back())->ice_datagram();
subscriberIdentities.push_back(object->ice_getIdentity());
topic->subscribeAndGetPublisher(IceStorm::QoS(), object);
adpt->activate();
}
{
// Use a separate adapter to ensure a separate connection is used for the subscriber
// (otherwise, if multiple UDP subscribers use the same connection we might get high
// packet loss, see bug 1784).
ObjectAdapterPtr adpt = communicator->createObjectAdapterWithEndpoints("UdpAdapter4", "udp");
subscribers.push_back(new SingleI(communicator, "batch datagram"));
Ice::ObjectPrx object = adpt->addWithUUID(subscribers.back())->ice_batchDatagram();
subscriberIdentities.push_back(object->ice_getIdentity());
topic->subscribeAndGetPublisher(IceStorm::QoS(), object);
adpt->activate();
}
adapter->activate();
vector<Ice::Identity> ids = topic->getSubscribers();
test(ids.size() == subscriberIdentities.size());
for(vector<Ice::Identity>::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
test(find(subscriberIdentities.begin(), subscriberIdentities.end(), *i) != subscriberIdentities.end());
}
for(vector<SingleIPtr>::const_iterator p = subscribers.begin(); p != subscribers.end(); ++p)
{
(*p)->waitForEvents();
}
return EXIT_SUCCESS;
}