Skip to content

Commit

Permalink
Spec complete for sending and receiving messages
Browse files Browse the repository at this point in the history
  • Loading branch information
umair-ably committed Oct 8, 2024
2 parents 5f6c651 + 4da8e42 commit 368a91c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Example/AblyChatExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct ContentView: View {
func showMessages() async throws {
for await message in try await room().messages.subscribe(bufferingPolicy: .unbounded) {
withAnimation {
messages.insert(BasicListItem(id: message.timeserial, title: message.clientID ?? "Anonymous", text: message.text), at: 0)
messages.insert(BasicListItem(id: message.timeserial, title: message.clientID, text: message.text), at: 0)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/DefaultMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ private struct MessageSubscriptionWrapper {
var timeserial: TimeserialString
}

public final class DefaultMessages: Messages, HandlesDiscontinuity {
public final class DefaultMessages: Messages, EmitsDiscontinuities {
private let roomID: String
public let channel: RealtimeChannelProtocol
private let chatAPI: ChatAPI
Expand Down
15 changes: 0 additions & 15 deletions Sources/AblyChat/EmitsDiscontinuities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,3 @@ import Ably
public protocol EmitsDiscontinuities {
func subscribeToDiscontinuities() async -> Subscription<ARTErrorInfo>
}

/**
* Represents an object that has a channel and therefore may care about discontinuities.
*/
@MainActor
internal protocol HandlesDiscontinuity {
var channel: RealtimeChannelProtocol { get }

// var channel: RealtimeChannelProtocol? { get }
/**
* Called when a discontinuity is detected on the channel.
* @param reason The error that caused the discontinuity.
*/
func discontinuityDetected(reason: ARTErrorInfo?)
}
2 changes: 1 addition & 1 deletion Sources/AblyChat/Rooms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal actor DefaultRooms: Rooms {
self.realtime = realtime
self.clientOptions = clientOptions
self.logger = logger
self.chatAPI = ChatAPI(realtime: realtime)
chatAPI = ChatAPI(realtime: realtime)
}

internal func get(roomID: String, options: RoomOptions) throws -> any Room {
Expand Down

0 comments on commit 368a91c

Please sign in to comment.