Separate ConnectionOptions into AdvertisingOptions, ConnectionOptions and DiscoveryOptions everywhere in the core.

PiperOrigin-RevId: 422626306
This commit is contained in:
jfcarroll
2022-01-18 12:56:04 -08:00
committed by Copybara-Service
parent 04ec681865
commit 56eb46db06
57 changed files with 1087 additions and 1191 deletions
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,9 +17,9 @@
#include <string>
#include "absl/functional/bind_front.h"
#include "core/advertising_options.h"
#include "core/core.h"
#include "core/listeners.h"
#include "core/options.h"
#include "core/params.h"
#include "core/status.h"
#include "platform/base/byte_array.h"
@@ -37,7 +37,7 @@ using ::location::nearby::ByteArrayFromNSData;
using ::location::nearby::CppStringFromObjCString;
using ::location::nearby::ObjCStringFromCppString;
using ::location::nearby::connections::ConnectionListener;
using ::location::nearby::connections::ConnectionOptions;
using ::location::nearby::connections::AdvertisingOptions;
using ::location::nearby::connections::ConnectionRequestInfo;
using ::location::nearby::connections::ConnectionResponseInfo;
using ::location::nearby::connections::GNCStrategyToStrategy;
@@ -289,17 +289,21 @@ using ::location::nearby::connections::GNCAdvertiserConnectionListener;
advertiser->advertiserListener.get()),
};
advertiser.core->_core->StartAdvertising(CppStringFromObjCString(serviceId),
ConnectionOptions{
.strategy = GNCStrategyToStrategy(strategy),
.auto_upgrade_bandwidth = true,
.enforce_topology_constraints = true,
},
ConnectionRequestInfo{
.endpoint_info = ByteArrayFromNSData(endpointInfo),
.listener = std::move(listener),
},
ResultListener{});
advertiser.core->_core->StartAdvertising(
CppStringFromObjCString(serviceId),
AdvertisingOptions{
{
GNCStrategyToStrategy(strategy), // .strategy
location::nearby::connections::BooleanMediumSelector(), // .allowed
},
true, // .auto_upgrade_bandwidth
true, // .enforce_topology_constraints
},
ConnectionRequestInfo{
.endpoint_info = ByteArrayFromNSData(endpointInfo),
.listener = std::move(listener),
},
ResultListener{});
return advertiser;
}
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -18,9 +18,10 @@
#include <utility>
#include "absl/functional/bind_front.h"
#include "core/connection_options.h"
#include "core/core.h"
#include "core/discovery_options.h"
#include "core/listeners.h"
#include "core/options.h"
#include "core/status.h"
#include "platform/base/byte_array.h"
#import "platform/impl/ios/Source/GNCConnection.h"
@@ -35,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
using ::location::nearby::ByteArray;
using ::location::nearby::CppStringFromObjCString;
using ::location::nearby::connections::DiscoveryOptions;
using ::location::nearby::connections::ConnectionOptions;
using ::location::nearby::connections::DiscoveryListener;
using ::location::nearby::connections::DistanceInfo;
@@ -379,8 +381,10 @@ using ::location::nearby::connections::GNCDiscoveryListener;
};
discoverer.core->_core->StartDiscovery(CppStringFromObjCString(serviceId),
ConnectionOptions{
.strategy = GNCStrategyToStrategy(strategy),
DiscoveryOptions{
{
GNCStrategyToStrategy(strategy),
},
},
std::move(listener), ResultListener{});
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
#include <string>
#include "core/listeners.h"
#include "core/options.h"
#import "platform/impl/ios/Source/GNCAdvertiser.h"
#import "platform/impl/ios/Source/GNCConnection.h"
+7 -4
View File
@@ -60,11 +60,14 @@ std::string GetPayloadPath(PayloadId payload_id) {
// process is responsible for freeing this resource once it
// is no longer needed by calling CoTaskMemFree, whether
// SHGetKnownFolderPath succeeds or not.
char* fullpathUTF8 = new char((wcslen(basePath) + 1) * sizeof(char));
wcstombs(fullpathUTF8, basePath, (wcslen(basePath) + 1) * sizeof(char));
size_t bufferSize;
wcstombs_s(&bufferSize, NULL, 0, basePath, 0);
char* fullpathUTF8 = new char[bufferSize + 1];
memset(fullpathUTF8, 0, bufferSize);
wcstombs_s(&bufferSize, fullpathUTF8, bufferSize, basePath, bufferSize - 1);
std::string fullPath = std::string(fullpathUTF8);
auto retval = absl::StrCat(fullPath += "/", payload_id);
auto retval = absl::StrCat(fullPath += "\\", payload_id);
delete[] fullpathUTF8;
return retval;
}
} // namespace