Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpin ably-cocoa #215

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "20eda2776391659360fe1f5d5d8095daadf2aa748972649241e4432cdb687f89",
"originHash" : "77e4b2b661f9de38584f7d61ba62b95f5fe6ef751d01e208399bed3950246e2b",
"pins" : [
{
"identity" : "ably-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ably/ably-cocoa",
"state" : {
"revision" : "5ba7809f5de6e885e8bd4788f0e807f66fc1875b",
"version" : "1.2.36"
"revision" : "35805d0e96a1df5b4dc0f6d82afe22ab753c15bd",
"version" : "1.2.37"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Example/AblyChatExample/Mocks/MockClients.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ actor MockRoom: Room {
actor MockMessages: Messages {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<Message>()

Expand Down Expand Up @@ -146,7 +146,7 @@ actor MockMessages: Messages {
actor MockRoomReactions: RoomReactions {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<Reaction>()

Expand Down Expand Up @@ -193,7 +193,7 @@ actor MockRoomReactions: RoomReactions {
actor MockTyping: Typing {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<TypingEvent>()

Expand Down Expand Up @@ -356,7 +356,7 @@ actor MockPresence: Presence {
actor MockOccupancy: Occupancy {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<OccupancyEvent>()

Expand Down
100 changes: 97 additions & 3 deletions Example/AblyChatExample/Mocks/MockRealtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ final class MockRealtime: NSObject, RealtimeClientProtocol, Sendable {
fatalError("Not implemented")
}

var presence: ARTRealtimePresenceProtocol {
fatalError("Not implemented")
}
let presence = RealtimePresence()

var errorReason: ARTErrorInfo? {
fatalError("Not implemented")
Expand Down Expand Up @@ -250,6 +248,102 @@ final class MockRealtime: NSObject, RealtimeClientProtocol, Sendable {
}
}

final class RealtimePresence: RealtimePresenceProtocol {
var syncComplete: Bool {
fatalError("Not implemented")
}

func get(_: @escaping ARTPresenceMessagesCallback) {
fatalError("Not implemented")
}

func get(_: ARTRealtimePresenceQuery, callback _: @escaping ARTPresenceMessagesCallback) {
fatalError("Not implemented")
}

func enter(_: Any?) {
fatalError("Not implemented")
}

func enter(_: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func update(_: Any?) {
fatalError("Not implemented")
}

func update(_: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func leave(_: Any?) {
fatalError("Not implemented")
}

func leave(_: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func enterClient(_: String, data _: Any?) {
fatalError("Not implemented")
}

func enterClient(_: String, data _: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func updateClient(_: String, data _: Any?) {
fatalError("Not implemented")
}

func updateClient(_: String, data _: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func leaveClient(_: String, data _: Any?) {
fatalError("Not implemented")
}

func leaveClient(_: String, data _: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func subscribe(_: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func subscribe(attachCallback _: ARTCallback?, callback _: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func subscribe(_: ARTPresenceAction, callback _: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func subscribe(_: ARTPresenceAction, onAttach _: ARTCallback?, callback _: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func unsubscribe() {
fatalError("Not implemented")
}

func unsubscribe(_: ARTEventListener) {
fatalError("Not implemented")
}

func unsubscribe(_: ARTPresenceAction, listener _: ARTEventListener) {
fatalError("Not implemented")
}

func history(_: @escaping ARTPaginatedPresenceCallback) {}

func history(_: ARTRealtimeHistoryQuery?, callback _: @escaping ARTPaginatedPresenceCallback) throws {
fatalError("Not implemented")
}
}
lawrence-forooghian marked this conversation as resolved.
Show resolved Hide resolved

required init(options _: ARTClientOptions) {}

required init(key _: String) {}
Expand Down
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "f5dd87027f1300f852cf86019686409a47c851bc11433a4138c8956b8a09ad6f",
"originHash" : "8c7acde3826a921568cc75459ff2052ebec85d53398758c637099c1128f45e32",
"pins" : [
{
"identity" : "ably-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ably/ably-cocoa",
"state" : {
"revision" : "5ba7809f5de6e885e8bd4788f0e807f66fc1875b",
"version" : "1.2.36"
"revision" : "35805d0e96a1df5b4dc0f6d82afe22ab753c15bd",
"version" : "1.2.37"
}
},
{
Expand Down
7 changes: 1 addition & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/ably/ably-cocoa",
/*
The upcoming ably-cocoa 1.2.37 will revert a change on which the Chat SDK depends. It will not be possible to make a single version of the Chat SDK work with ably-cocoa versions 1.2.36 and 1.2.37.

So, in order to make sure that the Chat SDK continues to work once ably-cocoa 1.2.37 is released, let's temporarily lock the ably-cocoa dependency to 1.2.36, and release a new version of the Chat SDK. Then, once ably-cocoa 1.2.37 is released, we can release another version of the Chat SDK that requires 1.2.37 and above.
*/
exact: "1.2.36"
from: "1.2.37"
),
.package(
url: "https://github.com/apple/swift-argument-parser",
Expand Down
2 changes: 2 additions & 0 deletions Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ extension ARTRealtimeChannels: RealtimeChannelsProtocol {}

extension ARTRealtimeChannel: RealtimeChannelProtocol {}

extension ARTRealtimePresence: RealtimePresenceProtocol {}

extension ARTConnection: ConnectionProtocol {}
14 changes: 9 additions & 5 deletions Sources/AblyChat/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ public protocol RealtimeClientProtocol: ARTRealtimeProtocol, Sendable {
associatedtype Channels: RealtimeChannelsProtocol
associatedtype Connection: ConnectionProtocol

// It’s not clear to me why ARTRealtimeProtocol doesn’t include this property. I briefly tried adding it but ran into compilation failures that it wasn’t immediately obvious how to fix.
var channels: Channels { get }

// TODO: Expose `Connection` on ARTRealtimeProtocol so it can be used from RealtimeClientProtocol - https://github.com/ably-labs/ably-chat-swift/issues/123
var connection: Connection { get }
}

/// Expresses the requirements of the object returned by ``RealtimeClientProtocol/channels``.
public protocol RealtimeChannelsProtocol: ARTRealtimeChannelsProtocol, Sendable {
associatedtype Channel: RealtimeChannelProtocol

// It’s not clear to me why ARTRealtimeChannelsProtocol doesn’t include this function (https://github.com/ably/ably-cocoa/issues/1968).
func get(_ name: String, options: ARTRealtimeChannelOptions) -> Channel
}

/// Expresses the requirements of the object returned by ``RealtimeChannelsProtocol/get(_:options:)``.
public protocol RealtimeChannelProtocol: ARTRealtimeChannelProtocol, Sendable {}
public protocol RealtimeChannelProtocol: ARTRealtimeChannelProtocol, Sendable {
associatedtype Presence: RealtimePresenceProtocol

var presence: Presence { get }
}

/// Expresses the requirements of the object returned by ``RealtimeChannelProtocol/presence``.
public protocol RealtimePresenceProtocol: ARTRealtimePresenceProtocol, Sendable {}

/// Expresses the requirements of the object returned by ``RealtimeClientProtocol/connection``.
public protocol ConnectionProtocol: ARTConnectionProtocol, Sendable {}

/// Like (a subset of) `ARTRealtimeChannelOptions` but with value semantics. (It’s unfortunate that `ARTRealtimeChannelOptions` doesn’t have a `-copy` method.)
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public protocol Messages: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The realtime channel.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }
}

public extension Messages {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Occupancy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public protocol Occupancy: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The underlying Ably channel for occupancy events.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }
}

public extension Occupancy {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Room.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ internal actor DefaultRoom<LifecycleManagerFactory: RoomLifecycleManagerFactory>
}

private struct FeatureChannelPartialDependencies {
internal var channel: RealtimeChannelProtocol
internal var channel: any RealtimeChannelProtocol
internal var contributor: DefaultRoomLifecycleContributor
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/AblyChat/RoomFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal enum RoomFeature: CaseIterable {
/// - the discontinuities emitted by the room lifecycle
/// - the presence-readiness wait mechanism supplied by the room lifecycle
internal protocol FeatureChannel: Sendable, EmitsDiscontinuities {
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }

/// Waits until we can perform presence operations on the contributors of this room without triggering an implicit attach.
///
Expand All @@ -62,7 +62,7 @@ internal protocol FeatureChannel: Sendable, EmitsDiscontinuities {
}

internal struct DefaultFeatureChannel: FeatureChannel {
internal var channel: RealtimeChannelProtocol
internal var channel: any RealtimeChannelProtocol
internal var contributor: DefaultRoomLifecycleContributor
internal var roomLifecycleManager: RoomLifecycleManager

Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/RoomReactions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public protocol RoomReactions: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The realtime channel.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }

/**
* Subscribes a given listener to receive room-level reactions.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Typing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public protocol Typing: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The Ably realtime channel.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }
}

public extension Typing {
Expand Down
4 changes: 2 additions & 2 deletions Tests/AblyChatTests/Mocks/MockFeatureChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import Ably
@testable import AblyChat

final actor MockFeatureChannel: FeatureChannel {
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol
private var discontinuitySubscriptions = SubscriptionStorage<DiscontinuityEvent>()
private let resultOfWaitToBeAbleToPerformPresenceOperations: Result<Void, ARTErrorInfo>?

init(
channel: RealtimeChannelProtocol,
channel: any RealtimeChannelProtocol,
resultOfWaitToBeAblePerformPresenceOperations: Result<Void, ARTErrorInfo>? = nil
) {
self.channel = channel
Expand Down
4 changes: 1 addition & 3 deletions Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import Ably
import AblyChat

final class MockRealtimeChannel: NSObject, RealtimeChannelProtocol {
var presence: ARTRealtimePresenceProtocol {
fatalError("Not implemented")
}
let presence = MockRealtimePresence()

private let attachSerial: String?
private let channelSerial: String?
Expand Down
Loading
Loading