implement stoplisteningforincomingconnections

PiperOrigin-RevId: 540724954
This commit is contained in:
Anay Wadhera
2023-06-15 16:43:56 -07:00
committed by Copybara-Service
parent c829632879
commit 44fb9b4fa2
17 changed files with 210 additions and 4 deletions
@@ -33,6 +33,7 @@
#include "connections/implementation/offline_frames.h"
#include "connections/implementation/proto/offline_wire_formats.pb.h"
#include "connections/medium_selector.h"
#include "connections/status.h"
#include "connections/v3/connections_device.h"
#include "connections/v3/listeners.h"
#include "internal/flags/nearby_flags.h"
@@ -42,6 +43,7 @@
#include "internal/platform/cancelable_alarm.h"
#include "internal/platform/connection_info.h"
#include "internal/platform/count_down_latch.h"
#include "internal/platform/future.h"
#include "internal/platform/logging.h"
#include "internal/platform/wifi_lan_connection_info.h"
#include "proto/connections_enums.pb.h"
@@ -145,6 +147,17 @@ std::vector<ConnectionInfoVariant> BasePcpHandler::GetConnectionInfoFromResult(
return connection_infos;
}
void BasePcpHandler::StopListeningForIncomingConnections(ClientProxy* client) {
CountDownLatch latch(1);
RunOnPcpHandlerThread("stop-listening-for-incoming-conn",
[this, client, &latch]() RUN_ON_PCP_HANDLER_THREAD() {
StopListeningForIncomingConnectionsImpl(client);
client->StoppedListeningForIncomingConnections();
latch.CountDown();
});
WaitForLatch("StopListeningForIncomingConnections", &latch);
}
Status BasePcpHandler::StartAdvertising(
ClientProxy* client, const std::string& service_id,
const AdvertisingOptions& advertising_options,