From c98e7deadfbe9df5216424ea2ea34428b78322cb Mon Sep 17 00:00:00 2001 From: Marat Al Date: Mon, 11 Nov 2024 03:03:19 +0100 Subject: [PATCH] Temporary chat framework fixes (for tests to run without crashes/hangs). --- Sources/AblyChat/ChatClient.swift | 2 +- Sources/AblyChat/DefaultMessages.swift | 4 ++-- Sources/AblyChat/Errors.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/AblyChat/ChatClient.swift b/Sources/AblyChat/ChatClient.swift index 917a22f..79b27d9 100644 --- a/Sources/AblyChat/ChatClient.swift +++ b/Sources/AblyChat/ChatClient.swift @@ -28,7 +28,7 @@ public actor DefaultChatClient: ChatClient { } public nonisolated var clientID: String { - fatalError("Not yet implemented") + realtime.clientId ?? "" } } diff --git a/Sources/AblyChat/DefaultMessages.swift b/Sources/AblyChat/DefaultMessages.swift index d11b283..1048791 100644 --- a/Sources/AblyChat/DefaultMessages.swift +++ b/Sources/AblyChat/DefaultMessages.swift @@ -35,7 +35,7 @@ internal final class DefaultMessages: Messages, EmitsDiscontinuities { // (CHA-M4) Messages can be received via a subscription in realtime. internal func subscribe(bufferingPolicy: BufferingPolicy) async throws -> MessageSubscription { let uuid = UUID() - let timeserial = try await resolveSubscriptionStart() + let timeserial = channel.properties.channelSerial let messageSubscription = MessageSubscription( bufferingPolicy: bufferingPolicy ) { [weak self] queryOptions in @@ -44,7 +44,7 @@ internal final class DefaultMessages: Messages, EmitsDiscontinuities { } // (CHA-M4a) A subscription can be registered to receive incoming messages. Adding a subscription has no side effects on the status of the room or the underlying realtime channel. - subscriptionPoints[uuid] = .init(subscription: messageSubscription, timeserial: timeserial) + subscriptionPoints[uuid] = .init(subscription: messageSubscription, timeserial: timeserial ?? "") // (CHA-M4c) When a realtime message with name set to message.created is received, it is translated into a message event, which contains a type field with the event type as well as a message field containing the Message Struct. This event is then broadcast to all subscribers. // (CHA-M4d) If a realtime message with an unknown name is received, the SDK shall silently discard the message, though it may log at DEBUG or TRACE level. diff --git a/Sources/AblyChat/Errors.swift b/Sources/AblyChat/Errors.swift index d4d153c..d49b068 100644 --- a/Sources/AblyChat/Errors.swift +++ b/Sources/AblyChat/Errors.swift @@ -14,7 +14,7 @@ public enum ErrorCode: Int { /// ``Rooms.get(roomID:options:)`` was called with a different set of room options than was used on a previous call. You must first release the existing room instance using ``Rooms.release(roomID:)``. /// /// TODO this code is a guess, revisit in https://github.com/ably-labs/ably-chat-swift/issues/32 - case inconsistentRoomOptions = 1 + case inconsistentRoomOptions = 40000 case messagesAttachmentFailed = 102_001 case presenceAttachmentFailed = 102_002