Merge branch 'google3'

Change-Id: I99e72f30bb4b8f975d61a940a7c7b746dba07796
This commit is contained in:
Alexey Polyudov
2020-10-01 02:32:02 -07:00
8 changed files with 70 additions and 9 deletions
+4 -4
View File
@@ -30,11 +30,11 @@ BwuManager::BwuManager(
if (config_.bandwidth_upgrade_retry_delay == absl::ZeroDuration()) {
config_.bandwidth_upgrade_retry_delay = absl::Seconds(5);
}
if (config_.bandwidth_upgrade_retry_delay == absl::ZeroDuration()) {
config_.bandwidth_upgrade_retry_delay = absl::Seconds(10);
if (config_.bandwidth_upgrade_retry_max_delay == absl::ZeroDuration()) {
config_.bandwidth_upgrade_retry_max_delay = absl::Seconds(10);
}
if (config_.allow_upgrade_to.All(false)) {
config.allow_upgrade_to.web_rtc = true;
config_.allow_upgrade_to.web_rtc = true;
}
if (!handlers.empty()) {
handlers_ = std::move(handlers);
@@ -43,7 +43,7 @@ BwuManager::BwuManager(
}
// Register the offline frame processor.
endpoint_manager.RegisterFrameProcessor(
endpoint_manager_->RegisterFrameProcessor(
V1Frame::BANDWIDTH_UPGRADE_NEGOTIATION, this);
}
+3
View File
@@ -136,6 +136,9 @@ ExceptionOr<bool> EndpointManager::HandleData(
// no explicit handler.
if (frame_type == V1Frame::KEEP_ALIVE) {
NEARBY_LOG(INFO, "KeepAlive message for: id=%s", endpoint_id.c_str());
} else if (frame_type == V1Frame::DISCONNECTION) {
NEARBY_LOG(INFO, "Disconnect message for: id=%s", endpoint_id.c_str());
endpoint_channel->Close();
} else {
NEARBY_LOG(ERROR, "Unhandled message: id=%s, type=%d",
endpoint_id.c_str(), frame_type);
+11
View File
@@ -254,6 +254,17 @@ ByteArray ForKeepAlive() {
return ToBytes(std::move(frame));
}
ByteArray ForDisconnection() {
OfflineFrame frame;
frame.set_version(OfflineFrame::V1);
auto* v1_frame = frame.mutable_v1();
v1_frame->set_type(V1Frame::DISCONNECTION);
v1_frame->mutable_disconnection();
return ToBytes(std::move(frame));
}
UpgradePathInfo::Medium MediumToUpgradePathInfoMedium(Medium medium) {
switch (medium) {
case Medium::MDNS:
@@ -13,9 +13,18 @@ P2pPointToPointPcpHandler::P2pPointToPointPcpHandler(
std::vector<proto::connections::Medium>
P2pPointToPointPcpHandler::GetConnectionMediumsByPriority() {
std::vector<proto::connections::Medium> mediums;
if (mediums_->GetWifiLan().IsAvailable()) {
mediums.push_back(proto::connections::WIFI_LAN);
}
if (mediums_->GetWebRtc().IsAvailable()) {
mediums.push_back(proto::connections::WEB_RTC);
}
if (mediums_->GetBluetoothClassic().IsAvailable()) {
mediums.push_back(proto::connections::BLUETOOTH);
}
if (mediums_->GetBle().IsAvailable()) {
mediums.push_back(proto::connections::BLE);
}
return mediums;
}
@@ -16,9 +16,18 @@ P2pStarPcpHandler::P2pStarPcpHandler(Mediums& mediums,
std::vector<proto::connections::Medium>
P2pStarPcpHandler::GetConnectionMediumsByPriority() {
std::vector<proto::connections::Medium> mediums;
if (mediums_->GetWifiLan().IsAvailable()) {
mediums.push_back(proto::connections::WIFI_LAN);
}
if (mediums_->GetWebRtc().IsAvailable()) {
mediums.push_back(proto::connections::WEB_RTC);
}
if (mediums_->GetBluetoothClassic().IsAvailable()) {
mediums.push_back(proto::connections::BLUETOOTH);
}
if (mediums_->GetBle().IsAvailable()) {
mediums.push_back(proto::connections::BLE);
}
return mediums;
}