class ChatDomainImpl : ChatDomain
The Chat Repository exposes livedata objects to make it easier to build your chat UI. It intercepts the various low level events to ensure data stays in sync. Offline storage is handled using Room
A different Room database is used for different users. That's why it's mandatory to specify the user id when initializing the ChatRepository
repo.channel(type, id) returns a repo object with channel specific livedata object repo.queryChannels(query) returns a livedata object for the specific queryChannels query
repo.online livedata object indicates if you're online or not repo.totalUnreadCount livedata object returns the current unread count for this user repo.channelUnreadCount livedata object returns the number of unread channels for this user repo.errorEvents events for errors that happen while interacting with the chat
activeChannelMapImpl |
stores the mapping from cid to channelRepository var activeChannelMapImpl: ConcurrentHashMap<String, ChannelControllerImpl> |
activeQueryMapImpl |
stores the mapping from cid to channelRepository var activeQueryMapImpl: ConcurrentHashMap<QueryChannelsEntity, QueryChannelsControllerImpl> |
banned |
if the current user is banned or not val banned: LiveData<Boolean> |
channelUnreadCount |
the number of unread channels for the current user val channelUnreadCount: LiveData<Int> |
currentUser |
The current user object var currentUser: User |
errorEvents |
The error event livedata object is triggered when errors in the underlying components occure. The following example shows how to observe these errors val errorEvents: LiveData<Event<ChatError>> |
initialized |
if the client connection has been initialized val initialized: LiveData<Boolean> |
muted |
list of users that you've muted val muted: LiveData<List<Mute>> |
offlineEnabled |
if offline is enabled var offlineEnabled: Boolean |
online |
LiveData that indicates if we are currently online val online: LiveData<Boolean> |
retryPolicy |
The retry policy for retrying failed requests var retryPolicy: RetryPolicy |
totalUnreadCount |
The total unread message count for the current user. Depending on your app you'll want to show this or the channelUnreadCount val totalUnreadCount: LiveData<Int> |
useCases |
a helper object which lists all the initialized use cases for the chat domain var useCases: UseCaseHelper |
userPresence |
if we want to track user presence var userPresence: Boolean |
addError |
fun addError(error: ChatError): Unit |
channel |
fun channel(c: Channel): ChannelControllerImpl fun channel(cid: String): ChannelControllerImpl
repo.channel("messaging", "12") return a ChatChannelRepository fun channel(channelType: String, channelId: String): ChannelControllerImpl |
clean |
fun clean(): Unit |
connectionRecovered |
suspend fun connectionRecovered(recoveryNeeded: Boolean = false): Unit |
createChannel |
suspend fun createChannel(c: Channel): Result<Channel> |
disconnect |
suspend fun disconnect(): Unit |
generateMessageId |
fun generateMessageId(): String |
getActiveQueries |
fun getActiveQueries(): List<QueryChannelsControllerImpl> |
getChannelConfig |
fun getChannelConfig(channelType: String): Config |
getVersion |
fun getVersion(): String |
isActiveChannel |
fun isActiveChannel(cid: String): Boolean |
isInitialized |
fun isInitialized(): Boolean |
isOffline |
fun isOffline(): Boolean |
isOnline |
fun isOnline(): Boolean |
postInitialized |
fun postInitialized(): Unit |
postOffline |
fun postOffline(): Unit |
postOnline |
fun postOnline(): Unit |
queryChannels |
queryChannels fun queryChannels(filter: FilterObject, sort: QuerySort? = null): QueryChannelsControllerImpl |
queryEvents |
suspend fun queryEvents(cids: List<String>): List<ChatEvent> |
replayEventsForActiveChannels |
replay events for all active channels ensures that the cid you provide is active suspend fun replayEventsForActiveChannels(cid: String? = null): Result<List<ChatEvent>> |
retryFailedEntities |
suspend fun retryFailedEntities(): Unit |
runAndRetry |
suspend fun runAndRetry(runnable: () -> Call<*>): Result<*> |
selectAndEnrichChannel |
suspend fun selectAndEnrichChannel(channelId: String, pagination: QueryChannelPaginationRequest): ChannelEntityPair? suspend fun selectAndEnrichChannel(channelId: String, pagination: QueryChannelsPaginationRequest): ChannelEntityPair? |
selectAndEnrichChannels |
suspend fun selectAndEnrichChannels(channelIds: List<String>, pagination: QueryChannelsPaginationRequest): List<ChannelEntityPair> |
setBanned |
fun setBanned(newBanned: Boolean): Unit |
setChannelUnreadCount |
fun setChannelUnreadCount(newCount: Int): Unit |
setOffline |
fun setOffline(): Unit |
setOnline |
fun setOnline(): Unit |
setTotalUnreadCount |
fun setTotalUnreadCount(newCount: Int): Unit |
startListening |
Start listening to chat events and keep the room database in sync fun startListening(): Unit |
stopListening |
Stop listening to chat events fun stopListening(): Unit |
storeStateForChannel |
suspend fun storeStateForChannel(channel: Channel): Unit |
storeStateForChannels |
suspend fun storeStateForChannels(channelsResponse: List<Channel>): Unit |