mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Internal change
PiperOrigin-RevId: 365906963
This commit is contained in:
@@ -717,10 +717,12 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent(
|
||||
previous_endpoint_channel->DisableEncryption();
|
||||
previous_endpoint_channel->Write(parser::ForDisconnection());
|
||||
|
||||
// TODO(b/172380349): Match the Java implementation with no sleep call
|
||||
|
||||
// Wait for in-flight messages to reach their peers.
|
||||
SystemClock::Sleep(absl::Seconds(1));
|
||||
// Attempt to read the disconnect message from the previous channel. We don't
|
||||
// care whether we successfully read it or whether we get an exception here.
|
||||
// The idea is just to make sure the other side has had a chance to receive
|
||||
// the full SAFE_TO_CLOSE_PRIOR_CHANNEL message before we actually close the
|
||||
// channel. See b/172380349 for more context.
|
||||
previous_endpoint_channel->Read();
|
||||
previous_endpoint_channel->Close(DisconnectionReason::UPGRADED);
|
||||
|
||||
// Now that the old channel has been drained, we can unpause the new channel
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "core/internal/endpoint_manager.h"
|
||||
#include "core/internal/mediums/mediums.h"
|
||||
#include "core/internal/mediums/utils.h"
|
||||
#include "core/internal/offline_frames.h"
|
||||
#include "platform/public/system_clock.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -57,20 +58,30 @@ TEST(BwuManagerTest, CanInitiateBwu) {
|
||||
bwu_manager.Shutdown();
|
||||
}
|
||||
|
||||
TEST(BwuManagerTest, CanProcessPathAvailableFrame) {
|
||||
TEST(BwuManagerTest, CanProcessBandwidthUpgradeFrames) {
|
||||
ClientProxy client;
|
||||
std::string endpoint_id("EP_A");
|
||||
LocationHint location_hint = Utils::BuildLocationHint("US");
|
||||
Mediums mediums;
|
||||
EndpointChannelManager ecm;
|
||||
EndpointManager em{&ecm};
|
||||
BwuManager bwu_manager{mediums, em, ecm, {}, {}};
|
||||
|
||||
LocationHint location_hint = Utils::BuildLocationHint("US");
|
||||
ExceptionOr<OfflineFrame> wrapped_frame = parser::FromBytes(
|
||||
ExceptionOr<OfflineFrame> path_available_frame = parser::FromBytes(
|
||||
parser::ForBwuWebrtcPathAvailable("my_id", location_hint));
|
||||
bwu_manager.OnIncomingFrame(path_available_frame.result(), endpoint_id,
|
||||
&client, Medium::WEB_RTC);
|
||||
|
||||
bwu_manager.OnIncomingFrame(wrapped_frame.result(), endpoint_id, &client,
|
||||
ExceptionOr<OfflineFrame> last_write_frame =
|
||||
parser::FromBytes(parser::ForBwuLastWrite());
|
||||
bwu_manager.OnIncomingFrame(last_write_frame.result(), endpoint_id, &client,
|
||||
Medium::WEB_RTC);
|
||||
|
||||
ExceptionOr<OfflineFrame> safe_to_close_frame =
|
||||
parser::FromBytes(parser::ForBwuSafeToClose());
|
||||
bwu_manager.OnIncomingFrame(safe_to_close_frame.result(), endpoint_id,
|
||||
&client, Medium::WEB_RTC);
|
||||
|
||||
bwu_manager.Shutdown();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user