From b771238b225b7c8e21e082be7ff6258b1b3a5c98 Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Mon, 28 Oct 2024 15:31:08 -0300 Subject: [PATCH] =?UTF-8?q?Apply=20CHADR-062=E2=80=99s=20public=20API=20ch?= =?UTF-8?q?anges=20to=20Connection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we did for Room in 7e4460d (a lot fewer changes here, though, because we haven’t implemented Connection yet). --- Sources/AblyChat/Connection.swift | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Sources/AblyChat/Connection.swift b/Sources/AblyChat/Connection.swift index c53e954..5efa165 100644 --- a/Sources/AblyChat/Connection.swift +++ b/Sources/AblyChat/Connection.swift @@ -1,17 +1,13 @@ import Ably public protocol Connection: AnyObject, Sendable { - var status: any ConnectionStatus { get } -} - -public protocol ConnectionStatus: AnyObject, Sendable { - var current: ConnectionLifecycle { get } + var status: ConnectionStatus { get } // TODO: (https://github.com/ably-labs/ably-chat-swift/issues/12): consider how to avoid the need for an unwrap var error: ARTErrorInfo? { get } - func onChange(bufferingPolicy: BufferingPolicy) -> Subscription + func onStatusChange(bufferingPolicy: BufferingPolicy) -> Subscription } -public enum ConnectionLifecycle: Sendable { +public enum ConnectionStatus: Sendable { case initialized case connecting case connected @@ -21,13 +17,13 @@ public enum ConnectionLifecycle: Sendable { } public struct ConnectionStatusChange: Sendable { - public var current: ConnectionLifecycle - public var previous: ConnectionLifecycle + public var current: ConnectionStatus + public var previous: ConnectionStatus // TODO: (https://github.com/ably-labs/ably-chat-swift/issues/12): consider how to avoid the need for an unwrap public var error: ARTErrorInfo? public var retryIn: TimeInterval - public init(current: ConnectionLifecycle, previous: ConnectionLifecycle, error: ARTErrorInfo? = nil, retryIn: TimeInterval) { + public init(current: ConnectionStatus, previous: ConnectionStatus, error: ARTErrorInfo? = nil, retryIn: TimeInterval) { self.current = current self.previous = previous self.error = error