本文整理汇总了C++中DiscoveryQos::setDiscoveryScope方法的典型用法代码示例。如果您正苦于以下问题:C++ DiscoveryQos::setDiscoveryScope方法的具体用法?C++ DiscoveryQos::setDiscoveryScope怎么用?C++ DiscoveryQos::setDiscoveryScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscoveryQos
的用法示例。
在下文中一共展示了DiscoveryQos::setDiscoveryScope方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyDbusDiscoveryQosToJoynr
void DbusCapabilitiesUtil::copyDbusDiscoveryQosToJoynr(const joynr::messaging::types::Types::DiscoveryQos& dbusDiscoveryQos, DiscoveryQos& joynrDiscoveryQos) {
// copy arbitration strategy
switch (dbusDiscoveryQos.arbitrationStrategy) {
case joynr::messaging::types::Types::ArbitrationStrategy::FIXED_CHANNEL:
joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT);
break;
case joynr::messaging::types::Types::ArbitrationStrategy::HIGHEST_PRIORITY:
joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
break;
case joynr::messaging::types::Types::ArbitrationStrategy::KEYWORD:
joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::KEYWORD);
break;
case joynr::messaging::types::Types::ArbitrationStrategy::LOCAL_ONLY:
joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::LOCAL_ONLY);
break;
case joynr::messaging::types::Types::ArbitrationStrategy::NOT_SET:
joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::NOT_SET);
break;
default:
assert(false);
}
switch(dbusDiscoveryQos.discoveryScope) {
case joynr::messaging::types::Types::DiscoveryScope::GLOBAL_ONLY:
joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::GLOBAL_ONLY);
break;
case joynr::messaging::types::Types::DiscoveryScope::LOCAL_ONLY:
joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_ONLY);
break;
case joynr::messaging::types::Types::DiscoveryScope::LOCAL_THEN_GLOBAL:
joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_THEN_GLOBAL);
break;
case joynr::messaging::types::Types::DiscoveryScope::LOCAL_AND_GLOBAL:
joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_AND_GLOBAL);
break;
default:
assert(false);
}
joynrDiscoveryQos.setCacheMaxAge(dbusDiscoveryQos.cacheMaxAge);
joynrDiscoveryQos.setDiscoveryTimeout(dbusDiscoveryQos.discoveryTimeout);
joynrDiscoveryQos.setProviderMustSupportOnChange(dbusDiscoveryQos.providerMustSupportOnChange);
joynrDiscoveryQos.setRetryInterval(dbusDiscoveryQos.retryInterval);
// copy the custom parameters
auto parameterMap = dbusDiscoveryQos.customParameters;
for(auto it = parameterMap.begin(); it != parameterMap.end(); it++) {
joynr::messaging::types::Types::CustomParameter parameter = it->second;
// initialize the joynr parameter
joynrDiscoveryQos.addCustomParameter(QString::fromStdString(parameter.name),
QString::fromStdString(parameter.value));
}
}
示例2: init
void init(const std::string& settings)
{
ccRuntime =
JoynrClusterControllerRuntime::create(std::make_unique<joynr::Settings>(settings));
types::ProviderQos providerQos;
providerQos.setScope(joynr::types::ProviderScope::LOCAL);
testProvider = std::make_shared<MockTestProvider>();
providerParticipantId =
ccRuntime->registerProvider<tests::testProvider>(domain, testProvider, providerQos);
// Create a proxy
auto testProxyBuilder = ccRuntime->createProxyBuilder<tests::testProxy>(domain);
DiscoveryQos discoveryQos;
discoveryQos.setDiscoveryScope(types::DiscoveryScope::LOCAL_ONLY);
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
discoveryQos.setDiscoveryTimeoutMs(1000);
testProxy = testProxyBuilder->setMessagingQos(MessagingQos(MESSAGINGQOS_TTL))
->setDiscoveryQos(discoveryQos)
->build();
}
示例3: settings
TEST_F(MessageNotificationTest, messageToDisconnectedProviderCausesBroadcast)
{
// 1. register provider
auto testProvider = std::make_shared<tests::DefaulttestProvider>();
joynr::types::ProviderQos providerQos;
providerQos.setScope(joynr::types::ProviderScope::LOCAL);
std::string providerParticipantId =
libjoynrProviderRuntime->registerProvider<tests::testProvider>(
testDomain, testProvider, providerQos);
// 2. create proxy
DiscoveryQos discoveryQos;
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::LAST_SEEN);
discoveryQos.setDiscoveryScope(joynr::types::DiscoveryScope::LOCAL_ONLY);
MessagingQos messagingQos;
messagingQos.setTtl(5000);
auto testProxyBuilder = libjoynrProxyRuntime->createProxyBuilder<tests::testProxy>(testDomain);
auto testProxy =
testProxyBuilder->setMessagingQos(messagingQos)->setDiscoveryQos(discoveryQos)->build();
Settings settings(settingsPath);
SystemServicesSettings systemSettings(settings);
auto messageNotificationProxyBuilder =
libjoynrProxyRuntime->createProxyBuilder<joynr::system::MessageNotificationProxy>(
systemSettings.getDomain());
DiscoveryQos messagingNotificationDiscoveryQos;
messagingNotificationDiscoveryQos.setArbitrationStrategy(
DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT);
messagingNotificationDiscoveryQos.addCustomParameter(
"fixedParticipantId", systemSettings.getCcMessageNotificationProviderParticipantId());
messagingNotificationDiscoveryQos.setDiscoveryScope(joynr::types::DiscoveryScope::LOCAL_ONLY);
auto messageNotificationProxy = messageNotificationProxyBuilder->setMessagingQos(messagingQos)
->setDiscoveryQos(messagingNotificationDiscoveryQos)
->build();
// 3. subscribe to message notification broadcast
auto mockListener = std::make_shared<MockSubscriptionListener>();
EXPECT_CALL(*mockListener, onSubscribed(_)).Times(1);
EXPECT_CALL(*mockListener, onError(_)).Times(0);
joynr::system::MessageNotificationMessageQueuedForDeliveryBroadcastFilterParameters
filterParameters;
filterParameters.setParticipantId(providerParticipantId);
auto future = messageNotificationProxy->subscribeToMessageQueuedForDeliveryBroadcast(
filterParameters, mockListener, std::make_shared<OnChangeSubscriptionQos>());
std::string subscriptionId;
future->get(subscriptionId);
// 4. disconnect provider runtime
libjoynrProviderRuntime->shutdown();
libjoynrProviderRuntime.reset();
// 5. execute call on proxy while provider is not connected to cluster-controller
auto onSuccess = [](const std::int32_t&) { FAIL(); };
auto onError = [](const joynr::exceptions::JoynrRuntimeException&) {};
EXPECT_CALL(*mockListener, onReceive(Eq(providerParticipantId), _))
.WillOnce(ReleaseSemaphore(&semaphore));
testProxy->addNumbersAsync(1, 2, 3, onSuccess, onError);
// 6. wait for a broadcast message to arrive
ASSERT_TRUE(semaphore.waitFor(std::chrono::seconds(3)));
messageNotificationProxy->unsubscribeFromMessageQueuedForDeliveryBroadcast(subscriptionId);
}