From 6b55e22601377abdd46e6796349f7ad3e4aabacc Mon Sep 17 00:00:00 2001 From: evgeny Date: Fri, 30 Aug 2024 13:24:40 +0100 Subject: [PATCH] fix: add missing Rooms interface Added Rooms interface, that was missing during in public API PR --- .../src/main/java/com/ably/chat/ChatClient.kt | 2 +- .../src/main/java/com/ably/chat/Rooms.kt | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 chat-android/src/main/java/com/ably/chat/Rooms.kt diff --git a/chat-android/src/main/java/com/ably/chat/ChatClient.kt b/chat-android/src/main/java/com/ably/chat/ChatClient.kt index e043411..6a1d06d 100644 --- a/chat-android/src/main/java/com/ably/chat/ChatClient.kt +++ b/chat-android/src/main/java/com/ably/chat/ChatClient.kt @@ -12,7 +12,7 @@ interface ChatClient { /** * The rooms object, which provides access to chat rooms. */ - val room: Room + val rooms: Rooms /** * The underlying connection to Ably, which can be used to monitor the clients diff --git a/chat-android/src/main/java/com/ably/chat/Rooms.kt b/chat-android/src/main/java/com/ably/chat/Rooms.kt new file mode 100644 index 0000000..e4fd7ff --- /dev/null +++ b/chat-android/src/main/java/com/ably/chat/Rooms.kt @@ -0,0 +1,37 @@ +package com.ably.chat + +/** + * Manages the lifecycle of chat rooms. + */ +interface Rooms { + /** + * Get the client options used to create the Chat instance. + */ + val clientOptions: ClientOptions + + /** + * Gets a room reference by ID. The Rooms class ensures that only one reference + * exists for each room. A new reference object is created if it doesn't already + * exist, or if the one used previously was released using release(roomId). + * + * Always call `release(roomId)` after the Room object is no longer needed. + * + * @param roomId The ID of the room. + * @param options The options for the room. + * @throws {@link ErrorInfo} if a room with the same ID but different options already exists. + * @returns Room A new or existing Room object. + */ + fun get(roomId: String, options: RoomOptions): Room + + /** + * Release the Room object if it exists. This method only releases the reference + * to the Room object from the Rooms instance and detaches the room from Ably. It does not unsubscribe to any + * events. + * + * After calling this function, the room object is no-longer usable. If you wish to get the room object again, + * you must call {@link Rooms.get}. + * + * @param roomId The ID of the room. + */ + suspend fun release(roomId: String) +}