Skip to content

Commit

Permalink
Merge pull request #7 from ably-labs/fix/add-missing-interface
Browse files Browse the repository at this point in the history
fix: add missing Rooms interface
  • Loading branch information
ttypic authored Sep 3, 2024
2 parents 623b370 + 6b55e22 commit 3fd39eb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
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)
}

0 comments on commit 3fd39eb

Please sign in to comment.