Skip to content
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
12 changes: 6 additions & 6 deletions Example/AblyChatExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct ContentView: View {

try await room.attach()
try await showOccupancy(room: room)
try await room.presence.enter(data: ["status": "📱 Online"])
try await room.presence.enter(withData: ["status": "📱 Online"])

try await showMessages(room: room)
} catch {
Expand Down Expand Up @@ -275,7 +275,7 @@ struct ContentView: View {
}
}
}
let previousMessages = try await subscription.historyBeforeSubscribe(.init())
let previousMessages = try await subscription.historyBeforeSubscribe(withParams: .init())

for message in previousMessages.items {
switch message.action {
Expand Down Expand Up @@ -387,7 +387,7 @@ struct ContentView: View {
guard !newMessage.isEmpty else {
return
}
_ = try await room().messages.send(params: .init(text: newMessage))
_ = try await room().messages.send(withParams: .init(text: newMessage))
newMessage = ""
}

Expand Down Expand Up @@ -417,19 +417,19 @@ struct ContentView: View {

func sendRoomReaction(_ reaction: String) {
Task {
try await room().reactions.send(params: .init(name: reaction))
try await room().reactions.send(withParams: .init(name: reaction))
}
}

func addMessageReaction(_ reaction: String, messageSerial: String) {
Task {
try await room().messages.reactions.send(messageSerial: messageSerial, params: .init(name: reaction, type: .distinct))
try await room().messages.reactions.send(forMessageWithSerial: messageSerial, params: .init(name: reaction, type: .distinct))
}
}

func deleteMessageReaction(_ reaction: String, messageSerial: String) {
Task {
try await room().messages.reactions.delete(messageSerial: messageSerial, params: .init(name: reaction, type: .distinct))
try await room().messages.reactions.delete(forMessageWithSerial: messageSerial, params: .init(name: reaction, type: .distinct))
}
}

Expand Down
20 changes: 10 additions & 10 deletions Example/AblyChatExample/Mocks/MockClients.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ class MockMessages: Messages {
)
}

func history(options _: QueryOptions) async throws(ARTErrorInfo) -> some PaginatedResult<Message> {
func history(withOptions _: QueryOptions) async throws(ARTErrorInfo) -> some PaginatedResult<Message> {
MockMessagesPaginatedResult(clientID: clientID, roomName: roomName)
}

func send(params: SendMessageParams) async throws(ARTErrorInfo) -> Message {
func send(withParams params: SendMessageParams) async throws(ARTErrorInfo) -> Message {
let message = Message(
serial: "\(Date().timeIntervalSince1970)",
action: .create,
Expand Down Expand Up @@ -246,7 +246,7 @@ class MockMessageReactions: MessageReactions {
self.roomName = roomName
}

func send(messageSerial: String, params: SendMessageReactionParams) async throws(ARTErrorInfo) {
func send(forMessageWithSerial messageSerial: String, params: SendMessageReactionParams) async throws(ARTErrorInfo) {
reactions.append(
MessageReaction(
type: .distinct,
Expand All @@ -265,7 +265,7 @@ class MockMessageReactions: MessageReactions {
)
}

func delete(messageSerial: String, params: DeleteMessageReactionParams) async throws(ARTErrorInfo) {
func delete(forMessageWithSerial messageSerial: String, params: DeleteMessageReactionParams) async throws(ARTErrorInfo) {
reactions.removeAll { reaction in
reaction.messageSerial == messageSerial && reaction.name == params.name && reaction.clientID == clientID
}
Expand Down Expand Up @@ -319,7 +319,7 @@ class MockRoomReactions: RoomReactions {
self.roomName = roomName
}

func send(params: SendReactionParams) async throws(ARTErrorInfo) {
func send(withParams params: SendReactionParams) async throws(ARTErrorInfo) {
let reaction = RoomReaction(
name: params.name,
metadata: [:],
Expand Down Expand Up @@ -447,7 +447,7 @@ class MockPresence: Presence {
}
}

func get(params _: PresenceParams) async throws(ARTErrorInfo) -> [PresenceMember] {
func get(withParams _: PresenceParams) async throws(ARTErrorInfo) -> [PresenceMember] {
MockStrings.names.shuffled().map { name in
PresenceMember(
clientID: name,
Expand All @@ -458,15 +458,15 @@ class MockPresence: Presence {
}
}

func isUserPresent(clientID _: String) async throws(ARTErrorInfo) -> Bool {
func isUserPresent(withClientID _: String) async throws(ARTErrorInfo) -> Bool {
fatalError("Not yet implemented")
}

func enter() async throws(ARTErrorInfo) {
try await enter(dataForEvent: nil)
}

func enter(data: PresenceData) async throws(ARTErrorInfo) {
func enter(withData data: PresenceData) async throws(ARTErrorInfo) {
try await enter(dataForEvent: data)
}

Expand All @@ -489,7 +489,7 @@ class MockPresence: Presence {
try await update(dataForEvent: nil)
}

func update(data: PresenceData) async throws(ARTErrorInfo) {
func update(withData data: PresenceData) async throws(ARTErrorInfo) {
try await update(dataForEvent: data)
}

Expand All @@ -512,7 +512,7 @@ class MockPresence: Presence {
try await leave(dataForEvent: nil)
}

func leave(data: PresenceData) async throws(ARTErrorInfo) {
func leave(withData data: PresenceData) async throws(ARTErrorInfo) {
try await leave(dataForEvent: data)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ struct MockMessageSubscriptionResponse<PaginatedResult: AblyChat.PaginatedResult
private let _unsubscribe: () -> Void
private let previousMessages: @MainActor @Sendable (QueryOptions) async throws(ARTErrorInfo) -> PaginatedResult

func historyBeforeSubscribe(_ params: QueryOptions) async throws(ARTErrorInfo) -> PaginatedResult {
func historyBeforeSubscribe(withParams params: QueryOptions) async throws(ARTErrorInfo) -> PaginatedResult {
try await previousMessages(params)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/AblyChat/DefaultMessageReactions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal final class DefaultMessageReactions: MessageReactions {
}

// (CHA-MR4) Users should be able to send a reaction to a message via the `send` method of the `MessagesReactions` object
internal func send(messageSerial: String, params: SendMessageReactionParams) async throws(ARTErrorInfo) {
internal func send(forMessageWithSerial messageSerial: String, params: SendMessageReactionParams) async throws(ARTErrorInfo) {
do {
var count = params.count
if params.type == .multiple, params.count == nil {
Expand All @@ -40,7 +40,7 @@ internal final class DefaultMessageReactions: MessageReactions {
}

// (CHA-MR11) Users should be able to delete a reaction from a message via the `delete` method of the `MessagesReactions` object
internal func delete(messageSerial: String, params: DeleteMessageReactionParams) async throws(ARTErrorInfo) {
internal func delete(forMessageWithSerial messageSerial: String, params: DeleteMessageReactionParams) async throws(ARTErrorInfo) {
let reactionType = params.type ?? options.defaultMessageReactionType
if reactionType != .unique, params.name == nil {
throw ARTErrorInfo(chatError: .unableDeleteReactionWithoutName(reactionType: reactionType.rawValue))
Expand Down
4 changes: 2 additions & 2 deletions Sources/AblyChat/DefaultMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ internal final class DefaultMessages: Messages {
}

// (CHA-M6a) A method must be exposed that accepts the standard Ably REST API query parameters. It shall call the "REST API"#rest-fetching-messages and return a PaginatedResult containing messages, which can then be paginated through.
internal func history(options: QueryOptions) async throws(ARTErrorInfo) -> some PaginatedResult<Message> {
internal func history(withOptions options: QueryOptions) async throws(ARTErrorInfo) -> some PaginatedResult<Message> {
do {
return try await chatAPI.getMessages(roomName: roomName, params: options)
} catch {
throw error.toARTErrorInfo()
}
}

internal func send(params: SendMessageParams) async throws(ARTErrorInfo) -> Message {
internal func send(withParams params: SendMessageParams) async throws(ARTErrorInfo) -> Message {
do {
return try await chatAPI.sendMessage(roomName: roomName, params: params)
} catch {
Expand Down
10 changes: 5 additions & 5 deletions Sources/AblyChat/DefaultPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal final class DefaultPresence: Presence {
}
}

internal func get(params: PresenceParams) async throws(ARTErrorInfo) -> [PresenceMember] {
internal func get(withParams params: PresenceParams) async throws(ARTErrorInfo) -> [PresenceMember] {
do throws(InternalError) {
logger.log(message: "Getting presence with params: \(params)", level: .debug)

Expand All @@ -68,7 +68,7 @@ internal final class DefaultPresence: Presence {
}

// (CHA-PR5) It must be possible to query if a given clientId is in the presence set.
internal func isUserPresent(clientID: String) async throws(ARTErrorInfo) -> Bool {
internal func isUserPresent(withClientID clientID: String) async throws(ARTErrorInfo) -> Bool {
do throws(InternalError) {
logger.log(message: "Checking if user is present with clientID: \(clientID)", level: .debug)

Expand All @@ -94,7 +94,7 @@ internal final class DefaultPresence: Presence {
}
}

internal func enter(data: PresenceData) async throws(ARTErrorInfo) {
internal func enter(withData data: PresenceData) async throws(ARTErrorInfo) {
try await enter(optionalData: data)
}

Expand Down Expand Up @@ -126,7 +126,7 @@ internal final class DefaultPresence: Presence {
}
}

internal func update(data: PresenceData) async throws(ARTErrorInfo) {
internal func update(withData data: PresenceData) async throws(ARTErrorInfo) {
try await update(optionalData: data)
}

Expand Down Expand Up @@ -158,7 +158,7 @@ internal final class DefaultPresence: Presence {
}
}

internal func leave(data: PresenceData) async throws(ARTErrorInfo) {
internal func leave(withData data: PresenceData) async throws(ARTErrorInfo) {
try await leave(optionalData: data)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/DefaultRoomReactions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal final class DefaultRoomReactions: RoomReactions {

// (CHA-ER3) Ephemeral room reactions are sent to Ably via the Realtime connection via a send method.
// (CHA-ER3d) Reactions are sent on the channel using a message in a particular format - see spec for format.
internal func send(params: SendReactionParams) async throws(ARTErrorInfo) {
internal func send(withParams params: SendReactionParams) async throws(ARTErrorInfo) {
do {
logger.log(message: "Sending reaction with params: \(params)", level: .debug)

Expand Down
4 changes: 2 additions & 2 deletions Sources/AblyChat/MessageReactions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public protocol MessageReactions: AnyObject, Sendable {
*
* - Note: It is possible to receive your own reaction via the reactions subscription before this method returns.
*/
func send(messageSerial: String, params: SendMessageReactionParams) async throws(ARTErrorInfo)
func send(forMessageWithSerial messageSerial: String, params: SendMessageReactionParams) async throws(ARTErrorInfo)

/**
* Delete a message reaction.
Expand All @@ -28,7 +28,7 @@ public protocol MessageReactions: AnyObject, Sendable {
* - messageSerial: A serial of the message to remove the reaction from.
* - params: The type of reaction annotation and the specific reaction to remove. The reaction to remove is required for all types except ``MessageReactionType/unique``.
*/
func delete(messageSerial: String, params: DeleteMessageReactionParams) async throws(ARTErrorInfo)
func delete(forMessageWithSerial messageSerial: String, params: DeleteMessageReactionParams) async throws(ARTErrorInfo)

/**
* Subscribe to message reaction summaries. Use this to keep message reaction counts up to date efficiently in the UI.
Expand Down
6 changes: 3 additions & 3 deletions Sources/AblyChat/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public protocol Messages: AnyObject, Sendable {
*
* - Returns: A paginated result object that can be used to fetch more messages if available.
*/
func history(options: QueryOptions) async throws(ARTErrorInfo) -> HistoryResult
func history(withOptions options: QueryOptions) async throws(ARTErrorInfo) -> HistoryResult

/**
* Send a message in the chat room.
Expand All @@ -47,7 +47,7 @@ public protocol Messages: AnyObject, Sendable {
*
* - Note: It is possible to receive your own message via the messages subscription before this method returns.
*/
func send(params: SendMessageParams) async throws(ARTErrorInfo) -> Message
func send(withParams params: SendMessageParams) async throws(ARTErrorInfo) -> Message

/**
* Updates a message in the chat room.
Expand Down Expand Up @@ -391,7 +391,7 @@ public final class MessageSubscriptionAsyncSequence<HistoryResult: PaginatedResu
}

// swiftlint:disable:next missing_docs
public func getPreviousMessages(params: QueryOptions) async throws(ARTErrorInfo) -> HistoryResult {
public func getPreviousMessages(withParams params: QueryOptions) async throws(ARTErrorInfo) -> HistoryResult {
try await getPreviousMessages(params)
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/AblyChat/Presence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public protocol Presence: AnyObject, Sendable {
*
* - Throws: An `ARTErrorInfo`.
*/
func get(params: PresenceParams) async throws(ARTErrorInfo) -> [PresenceMember]
func get(withParams params: PresenceParams) async throws(ARTErrorInfo) -> [PresenceMember]

/**
* Method to check if user with supplied clientId is online.
Expand All @@ -41,7 +41,7 @@ public protocol Presence: AnyObject, Sendable {
*
* - Throws: An `ARTErrorInfo`.
*/
func isUserPresent(clientID: String) async throws(ARTErrorInfo) -> Bool
func isUserPresent(withClientID clientID: String) async throws(ARTErrorInfo) -> Bool

/**
* Method to join room presence, will emit an enter event to all subscribers. Repeat calls will trigger more enter events.
Expand All @@ -51,7 +51,7 @@ public protocol Presence: AnyObject, Sendable {
*
* - Throws: An `ARTErrorInfo`.
*/
func enter(data: PresenceData) async throws(ARTErrorInfo)
func enter(withData data: PresenceData) async throws(ARTErrorInfo)

/**
* Method to update room presence, will emit an update event to all subscribers. If the user is not present, it will be treated as a join event.
Expand All @@ -61,7 +61,7 @@ public protocol Presence: AnyObject, Sendable {
*
* - Throws: An `ARTErrorInfo`.
*/
func update(data: PresenceData) async throws(ARTErrorInfo)
func update(withData data: PresenceData) async throws(ARTErrorInfo)

/**
* Method to leave room presence, will emit a leave event to all subscribers. If the user is not present, it will be treated as a no-op.
Expand All @@ -71,7 +71,7 @@ public protocol Presence: AnyObject, Sendable {
*
* - Throws: An `ARTErrorInfo`.
*/
func leave(data: PresenceData) async throws(ARTErrorInfo)
func leave(withData data: PresenceData) async throws(ARTErrorInfo)

/**
* Subscribes a given listener to a particular presence event in the chat room.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/RoomReactions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public protocol RoomReactions: AnyObject, Sendable {
*
* - Note: It is possible to receive your own reaction via the reactions subscription before this method returns.
*/
func send(params: SendReactionParams) async throws(ARTErrorInfo)
func send(withParams params: SendReactionParams) async throws(ARTErrorInfo)

/**
* Subscribes a given listener to the room reactions.
Expand Down
4 changes: 2 additions & 2 deletions Sources/AblyChat/Subscription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public protocol MessageSubscriptionResponse: Subscription, Sendable {
*
* - Returns: A paginated result of messages, in newest-to-oldest order.
*/
func historyBeforeSubscribe(_ params: QueryOptions) async throws(ARTErrorInfo) -> HistoryResult
func historyBeforeSubscribe(withParams params: QueryOptions) async throws(ARTErrorInfo) -> HistoryResult
}

internal struct DefaultSubscription: Subscription, Sendable {
Expand Down Expand Up @@ -91,7 +91,7 @@ internal struct DefaultMessageSubscriptionResponse: MessageSubscriptionResponse,
_unsubscribe()
}

internal func historyBeforeSubscribe(_ params: QueryOptions) async throws(ARTErrorInfo) -> some PaginatedResult<Message> {
internal func historyBeforeSubscribe(withParams params: QueryOptions) async throws(ARTErrorInfo) -> some PaginatedResult<Message> {
do {
let fromSerial = try await subscriptionStartSerial()

Expand Down
Loading