Closed ttypic closed 1 month ago
The changes primarily involve refactoring and enhancing the chat functionality in the Ably library. Key updates include the introduction of a ChatClient
, modifications to message retrieval and subscription methods, and the addition of utility functions for JSON handling. The structure of several classes has been adjusted for better encapsulation and usability, while new test cases have been created to ensure the reliability of these functionalities.
Files | Change Summary |
---|---|
chat-android/src/main/java/com/ably/chat/ChatApi.kt |
Changed class visibility to internal, updated getMessages to include an optional parameter fromSerial , and removed several private utility functions. |
chat-android/src/main/java/com/ably/chat/ChatClient.kt |
Modified ChatClient function to provide a default value for clientOptions , making it optional. |
chat-android/src/main/java/com/ably/chat/JsonUtils.kt |
Introduced utility functions for JSON handling, enhancing type safety and error reporting. |
chat-android/src/main/java/com/ably/chat/Messages.kt |
Updated MessagesSubscription interface to allow optional parameters for message retrieval, added DefaultMessagesSubscription , and improved message handling. |
chat-android/src/main/java/com/ably/chat/Room.kt |
Restructured DefaultRoom to improve encapsulation of the messages property and added a release() method. |
chat-android/src/main/java/com/ably/chat/RoomOptions.kt |
Changed properties to use singleton instances instead of instantiable classes for RoomReactionsOptions and OccupancyOptions . |
chat-android/src/main/java/com/ably/chat/Rooms.kt |
Updated get function to provide a default RoomOptions , changed map type to MutableMap<String, DefaultRoom> , and improved resource management in release . |
chat-android/src/main/java/com/ably/chat/Utils.kt |
Added DeferredValue<T> class for deferred value handling and improved null handling in ChatChannelOptions . |
chat-android/src/test/java/com/ably/chat/ChatApiTest.kt |
Refactored test setup for clarity and maintainability, introducing helper functions for mocking API responses. |
chat-android/src/test/java/com/ably/chat/MessagesTest.kt |
Introduced comprehensive unit tests for DefaultMessages functionality, covering message sending and subscription management. |
chat-android/src/test/java/com/ably/chat/TestUtils.kt |
Added utility functions for mocking API responses, streamlining the testing process. |
chat-android/src/test/java/io/ably/lib/realtime/RealtimeUtils.kt |
Introduced utility functions for building channel state changes and real-time channels. |
example/src/main/java/com/ably/chat/example/MainActivity.kt |
Transitioned from ChatApi to ChatClient , simplifying message handling and subscription lifecycle management. |
Objective | Addressed | Explanation |
---|---|---|
Implement sending and receiving chat messages (ECO-4943) | β |
π° In the meadow, a chat does bloom,
With messages flying, dispelling the gloom.
A client now dances, swift and light,
Sending and receiving, oh what a sight!
With JSON helpers, the code is neat,
Hopping along, our chat's now complete! πΌ
Resolves https://github.com/ably-labs/ably-chat-kotlin/issues/2
In this PR, we introduce the basic implementation for sending and receiving messages. Corner cases and potential race conditions are not the focus at this stage and will be addressed later, once Room lifecycle management is implemented and a unified test suite is set up.
Summary by CodeRabbit
Release Notes
New Features
ChatClient
for message handling.Improvements
Refactor