From 51db5752fc67cc59bd52a70f2d96e351d8ead13f 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 9130458c924..102671bd45e 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(withCompletionHandler: completionHandler) + } } extension ConnectionManager: InternalPayloadDelegate {