From b944d041d863d7fc4353fecfe4afbf255a2535d9 Mon Sep 17 00:00:00 2001 From: Nick Bourdakos Date: Mon, 23 Sep 2024 14:09:25 -0700 Subject: [PATCH] Add `stopAllEndpoints` API to Swift `ConnectionManager` PiperOrigin-RevId: 677933570 --- .../Sources/ConnectionManager.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/connections/swift/NearbyConnections/Sources/ConnectionManager.swift b/connections/swift/NearbyConnections/Sources/ConnectionManager.swift index 9130458c92..175921af54 100644 --- a/connections/swift/NearbyConnections/Sources/ConnectionManager.swift +++ b/connections/swift/NearbyConnections/Sources/ConnectionManager.swift @@ -213,6 +213,18 @@ public class ConnectionManager { withCompletionHandler: completionHandler ) } + + /// Disconnects from, and removes all traces of, all connected and/or discovered endpoints. + /// + /// This call is expected to be preceded by a call to stop advertising or discovery as needed. + /// After calling this method, no further operations with remote endpoints will be possible until + /// a new call to start advertising or discovery. + /// + /// - Parameters: + /// - completionHandler: Called when all endpoints have been disconnected and removed. + public func stopAllEndpoints(completionHandler: ((Error?) -> Void)? = nil) { + GNCCoreAdapter.shared.stopAllEndpoints(completionHandler: completionHandler) + } } extension ConnectionManager: InternalPayloadDelegate {