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

fix: add missing Rooms interface #7

Merged
merged 1 commit into from
Sep 3, 2024
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
2 changes: 1 addition & 1 deletion chat-android/src/main/java/com/ably/chat/ChatClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions chat-android/src/main/java/com/ably/chat/Rooms.kt
Original file line number Diff line number Diff line change
@@ -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)
}