Skip to content

Commit

Permalink
Apply CHADR-062’s public API changes to Connection
Browse files Browse the repository at this point in the history
As we did for Room in 7e4460d (a lot fewer changes here, though, because
we haven’t implemented Connection yet).
  • Loading branch information
lawrence-forooghian committed Nov 6, 2024
1 parent b39621c commit b771238
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Sources/AblyChat/Connection.swift
Original file line number Diff line number Diff line change
@@ -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<ConnectionStatusChange>
func onStatusChange(bufferingPolicy: BufferingPolicy) -> Subscription<ConnectionStatusChange>
}

public enum ConnectionLifecycle: Sendable {
public enum ConnectionStatus: Sendable {
case initialized
case connecting
case connected
Expand All @@ -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
Expand Down

0 comments on commit b771238

Please sign in to comment.