-
public interface ChatDomainThe ChatDomain is the main entry point for all flow & offline operations on chat.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classChatDomain.Builderpublic classChatDomain.Companion
-
Method Summary
Modifier and Type Method Description abstract Unitdisconnect()abstract BooleanisOnline()abstract BooleanisOffline()abstract BooleanisConnecting()abstract BooleanisInitialized()abstract List<QueryChannelsController>getActiveQueries()abstract Unitclean()abstract ConfiggetChannelConfig(String channelType)abstract StringgetVersion()abstract Call<List<ChatEvent>>replayEventsForActiveChannels(String cid)Adds the provided channel to the active channels and replays events for all active channels. abstract Call<ChannelController>getChannelController(String cid)Returns a ChannelController for given cid. abstract Call<ChannelController>watchChannel(String cid, Integer messageLimit)Watches the given channel and returns a ChannelController. abstract Call<QueryChannelsController>queryChannels(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit)Queries offline storage and the API for channels matching the filter. abstract Call<ThreadController>getThread(String cid, String parentId)Returns a thread controller for the given channel and message id. abstract Call<Channel>loadOlderMessages(String cid, Integer messageLimit)Loads older messages for the channel. abstract Call<Channel>loadNewerMessages(String cid, Integer messageLimit)Loads newer messages for the channel. abstract Call<Message>loadMessageById(String cid, String messageId, Integer olderMessagesOffset, Integer newerMessagesOffset)Loads message for a given message id and channel id. abstract Call<List<Channel>>queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit)Load more channels for this query. abstract Call<List<Channel>>queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort, Integer messageLimit)Load more channels for this query. abstract Call<List<Channel>>queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort)Load more channels for this query. abstract Call<List<Message>>threadLoadMore(String cid, String parentId, Integer messageLimit)Loads more messages for the specified thread. abstract Call<Channel>createChannel(Channel channel)Creates a new channel. abstract Call<Message>sendMessage(Message message)Sends the message. abstract Call<Boolean>cancelMessage(Message message)Cancels the message of "ephemeral" type. abstract Call<Message>shuffleGiphy(Message message)Performs giphy shuffle operation. abstract Call<Message>sendGiphy(Message message)Sends selected giphy message to the channel. abstract Call<Message>editMessage(Message message)Edits the specified message. abstract Call<Message>deleteMessage(Message message, Boolean hard)Deletes the specified message, request is retried according to the retry policy specified on the chatDomain. abstract Call<Message>deleteMessage(Message message)abstract Call<Reaction>sendReaction(String cid, Reaction reaction, Boolean enforceUnique)Sends the reaction. abstract Call<Message>deleteReaction(String cid, Reaction reaction)Deletes the specified reaction, request is retried according to the retry policy specified on the chatDomain. abstract Call<Boolean>keystroke(String cid, String parentId)Keystroke should be called whenever a user enters text into the message input. abstract Call<Boolean>stopTyping(String cid, String parentId)StopTyping should be called when the user submits the text and finishes typing. abstract Call<Boolean>markRead(String cid)Marks all messages of the specified channel as read. abstract Call<Boolean>markAllRead()Marks all messages on a channel as read. abstract Call<Unit>hideChannel(String cid, Boolean keepHistory)Hides the channel with the specified id. abstract Call<Unit>showChannel(String cid)Shows a channel that was previously hidden. abstract Call<Unit>leaveChannel(String cid)Leaves the channel with the specified id. abstract Call<Unit>deleteChannel(String cid)Deletes the channel with the specified id. abstract Call<Unit>setMessageForReply(String cid, Message message)Set the reply state for the channel. abstract Call<Unit>downloadAttachment(Attachment attachment)Downloads the selected attachment to the "Download" folder in the public external storage directory. abstract Call<List<User>>searchUsersByName(String querySearch, Integer offset, Integer userLimit, Boolean userPresence)Perform api request with a search string as autocomplete if in online state. abstract Call<List<Member>>queryMembers(String cid, Integer offset, Integer limit, FilterObject filter, QuerySort<Member> sort, List<Member> members)Query members of a channel. abstract StateFlow<User>getUser()The current user on the chatDomain object abstract BooleangetOfflineEnabled()if offline is enabled abstract UnitsetOfflineEnabled(Boolean offlineEnabled)if offline is enabled abstract BooleangetUserPresence()if we want to track user presence abstract UnitsetUserPresence(Boolean userPresence)if we want to track user presence abstract StateFlow<Boolean>getInitialized()if the client connection has been initialized abstract StateFlow<ConnectionState>getConnectionState()StateFlow<ConnectionState> that indicates if we are currently online, connecting of offline. abstract StateFlow<Integer>getTotalUnreadCount()The total unread message count for the current user. abstract StateFlow<Integer>getChannelUnreadCount()the number of unread channels for the current user abstract StateFlow<Event<ChatError>>getErrorEvents()The error event state flow object is triggered when errors in the underlying components occur. abstract StateFlow<List<Mute>>getMuted()list of users that you've muted abstract StateFlow<List<ChannelMute>>getChannelMutes()List of channels you've muted abstract StateFlow<Boolean>getBanned()if the current user is banned or not abstract RetryPolicygetRetryPolicy()The retry policy for retrying failed requests abstract StateFlow<TypingEvent>getTypingUpdates()Updates about currently typing users in active channels. -
-
Method Detail
-
disconnect
abstract Unit disconnect()
-
isConnecting
abstract Boolean isConnecting()
-
isInitialized
abstract Boolean isInitialized()
-
getActiveQueries
abstract List<QueryChannelsController> getActiveQueries()
-
getChannelConfig
abstract Config getChannelConfig(String channelType)
-
getVersion
abstract String getVersion()
-
replayEventsForActiveChannels
@CheckResult()@Deprecated(message = replayEventsForActiveChannels is deprecated. Use extension function ChatClient::replayEventsForActiveChannels instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().replayEventsForActiveChannels(attachment)), level = DeprecationLevel.ERROR) abstract Call<List<ChatEvent>> replayEventsForActiveChannels(String cid)
Adds the provided channel to the active channels and replays events for all active channels.
-
getChannelController
@CheckResult() abstract Call<ChannelController> getChannelController(String cid)
Returns a ChannelController for given cid.
- Parameters:
cid- The full channel id.
-
watchChannel
@CheckResult() abstract Call<ChannelController> watchChannel(String cid, Integer messageLimit)
Watches the given channel and returns a ChannelController.
- Parameters:
cid- The full channel id.messageLimit- How many messages to load on the first request.
-
queryChannels
@CheckResult() abstract Call<QueryChannelsController> queryChannels(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit)
Queries offline storage and the API for channels matching the filter.
- Parameters:
filter- The filter object.sort- How to sort the channels (default is last_message_at).limit- The number of channels to retrieve.messageLimit- How many messages to retrieve per channel.memberLimit- The number of members per channel.
-
getThread
@CheckResult() abstract Call<ThreadController> getThread(String cid, String parentId)
Returns a thread controller for the given channel and message id.
- Parameters:
cid- The full channel id.parentId- The message id for the parent of this thread.
-
loadOlderMessages
@CheckResult()@Deprecated(message = loadOlderMessages is deprecated. Use extension function ChatClient::loadOlderMessages instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().loadOlderMessages(cid, messageLimit)), level = DeprecationLevel.ERROR) abstract Call<Channel> loadOlderMessages(String cid, Integer messageLimit)
Loads older messages for the channel.
- Parameters:
cid- The full channel id i.messageLimit- How many new messages to load.
-
loadNewerMessages
@CheckResult() abstract Call<Channel> loadNewerMessages(String cid, Integer messageLimit)
Loads newer messages for the channel.
- Parameters:
cid- The full channel id i.messageLimit- How many new messages to load.
-
loadMessageById
@CheckResult() abstract Call<Message> loadMessageById(String cid, String messageId, Integer olderMessagesOffset, Integer newerMessagesOffset)
Loads message for a given message id and channel id.
- Parameters:
cid- The full channel id i.messageId- The id of the message.olderMessagesOffset- How many new messages to load before the requested message.newerMessagesOffset- How many new messages to load after the requested message.
-
queryChannelsLoadMore
@CheckResult() abstract Call<List<Channel>> queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit)
Load more channels for this query.
- Parameters:
filter- The filter for querying channels, see https://getstream.io/chat/docs/query_channels/?language=kotlin.sort- The sort for the channels, by default will sort on last_message_at.limit- The number of channels to retrieve.messageLimit- How many messages to fetch per channel.memberLimit- The number of members per channel.
-
queryChannelsLoadMore
@CheckResult() abstract Call<List<Channel>> queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort, Integer messageLimit)
Load more channels for this query.
- Parameters:
filter- The filter for querying channels, see https://getstream.io/chat/docs/query_channels/?language=kotlin.sort- The sort for the channels, by default will sort on last_message_at.messageLimit- How many messages to fetch per channel.
-
queryChannelsLoadMore
@CheckResult() abstract Call<List<Channel>> queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort)
Load more channels for this query.
- Parameters:
filter- The filter for querying channels, see https://getstream.io/chat/docs/query_channels/?language=kotlin.sort- The sort for the channels, by default will sort on last_message_at.
-
threadLoadMore
@CheckResult() abstract Call<List<Message>> threadLoadMore(String cid, String parentId, Integer messageLimit)
Loads more messages for the specified thread.
- Parameters:
cid- The full channel id i.parentId- The parentId of the thread.messageLimit- How many new messages to load.
-
createChannel
@Deprecated(message = createChannel is deprecated. Use ChatClient::createChannel extension function instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().createChannel(channel)))@CheckResult() abstract Call<Channel> createChannel(Channel channel)
Creates a new channel. Will retry according to the retry policy if it fails.
- Parameters:
channel- The channel object.
-
sendMessage
@CheckResult() abstract Call<Message> sendMessage(Message message)
Sends the message. Immediately adds the message to local storage API call to send the message is retried according to the retry policy specified on the chatDomain.
- Parameters:
message- The message to send.
-
cancelMessage
@CheckResult()@Deprecated(message = cancelMessage is deprecated. Use extension function ChatClient::cancelMessage instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().cancelMessage(message)), level = DeprecationLevel.WARNING) abstract Call<Boolean> cancelMessage(Message message)
Cancels the message of "ephemeral" type. Removes the message from local storage. API call to remove the message is retried according to the retry policy specified on the chatDomain.
- Parameters:
message- The message to send.
-
shuffleGiphy
@CheckResult() abstract Call<Message> shuffleGiphy(Message message)
Performs giphy shuffle operation. Removes the original "ephemeral" message from local storage. Returns new "ephemeral" message with new giphy url. API call to remove the message is retried according to the retry policy specified on the chatDomain
- Parameters:
message- The message to send.
-
sendGiphy
@CheckResult() abstract Call<Message> sendGiphy(Message message)
Sends selected giphy message to the channel. Removes the original "ephemeral" message from local storage. Returns new "ephemeral" message with new giphy url. API call to remove the message is retried according to the retry policy specified on the chatDomain
- Parameters:
message- The message to send.
-
editMessage
@CheckResult() abstract Call<Message> editMessage(Message message)
Edits the specified message. Local storage is updated immediately. The API request is retried according to the retry policy specified on the chatDomain.
- Parameters:
message- The message to edit.
-
deleteMessage
@CheckResult() abstract Call<Message> deleteMessage(Message message, Boolean hard)
Deletes the specified message, request is retried according to the retry policy specified on the chatDomain.
- Parameters:
message- The message to mark as deleted.hard- Use to hard delete the message (delete in backend).
-
deleteMessage
abstract Call<Message> deleteMessage(Message message)
-
sendReaction
@CheckResult() abstract Call<Reaction> sendReaction(String cid, Reaction reaction, Boolean enforceUnique)
Sends the reaction. Immediately adds the reaction to local storage and updates the reaction fields on the related message. API call to send the reaction is retried according to the retry policy specified on the chatDomain.
- Parameters:
cid- The full channel id i.reaction- The reaction to add.enforceUnique- If set to true, new reaction will replace all reactions the user has on this message.
-
deleteReaction
@CheckResult() abstract Call<Message> deleteReaction(String cid, Reaction reaction)
Deletes the specified reaction, request is retried according to the retry policy specified on the chatDomain.
- Parameters:
cid- The full channel id, ie messaging:123.reaction- The reaction to mark as deleted.
-
keystroke
@CheckResult()@Deprecated(message = keystroke is deprecated. Use extension function ChatClient::keystroke instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().keystroke(cid, parentId)), level = DeprecationLevel.ERROR) abstract Call<Boolean> keystroke(String cid, String parentId)
Keystroke should be called whenever a user enters text into the message input. It automatically calls stopTyping when the user stops typing after 5 seconds.
- Parameters:
cid- The full channel id i.parentId- Set this field tomessage.idto indicate that typing event is happening in a thread.
-
stopTyping
@CheckResult()@Deprecated(message = stopTyping is deprecated. Use extension function ChatClient::stopTyping instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().stopTyping(cid, parentId)), level = DeprecationLevel.ERROR) abstract Call<Boolean> stopTyping(String cid, String parentId)
StopTyping should be called when the user submits the text and finishes typing.
- Parameters:
cid- The full channel id i.parentId- Set this field tomessage.idto indicate that typing event is happening in a thread.
-
markRead
@CheckResult() abstract Call<Boolean> markRead(String cid)
Marks all messages of the specified channel as read.
- Parameters:
cid- The full channel id i.
-
markAllRead
@CheckResult() abstract Call<Boolean> markAllRead()
Marks all messages on a channel as read.
-
hideChannel
@CheckResult() abstract Call<Unit> hideChannel(String cid, Boolean keepHistory)
Hides the channel with the specified id.
- Parameters:
cid- The full channel id i.keepHistory- Boolean, if you want to keep the history of this channel or not.
-
showChannel
@CheckResult()@Deprecated(message = Deprecated. Use ChatClient::showChannel instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().showChannel(channelType, channelId)), level = DeprecationLevel.ERROR) abstract Call<Unit> showChannel(String cid)
Shows a channel that was previously hidden.
- Parameters:
cid- The full channel id i.
-
leaveChannel
@CheckResult()@Deprecated(message = leaveChannel is deprecated. Use function ChatClient::removeMembers instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().removeMembers(channel.type, channel.id, listOf(userId))), level = DeprecationLevel.WARNING) abstract Call<Unit> leaveChannel(String cid)
Leaves the channel with the specified id.
- Parameters:
cid- The full channel id i.
-
deleteChannel
@CheckResult() abstract Call<Unit> deleteChannel(String cid)
Deletes the channel with the specified id.
- Parameters:
cid- The full channel id i.
-
setMessageForReply
@CheckResult()@Deprecated(message = setMessageForReply is deprecated. Use extension function ChatClient::setMessageForReply instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().setMessageForReply(attachment)), level = DeprecationLevel.ERROR) abstract Call<Unit> setMessageForReply(String cid, Message message)
Set the reply state for the channel.
- Parameters:
cid- CID of the channel where reply state is being set.message- The message we want reply to.
-
downloadAttachment
@CheckResult()@Deprecated(message = downloadAttachment is deprecated. Use extension function ChatClient::downloadAttachment instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.client.ChatClient}, expression = ChatClient.instance().downloadAttachment(attachment)), level = DeprecationLevel.ERROR) abstract Call<Unit> downloadAttachment(Attachment attachment)
Downloads the selected attachment to the "Download" folder in the public external storage directory.
- Parameters:
attachment- The attachment to download.
-
searchUsersByName
@CheckResult() abstract Call<List<User>> searchUsersByName(String querySearch, Integer offset, Integer userLimit, Boolean userPresence)
Perform api request with a search string as autocomplete if in online state. Otherwise performs search by name in local database.
- Parameters:
querySearch- Search string used as autocomplete.offset- Offset for paginated requests.userLimit- The page size in the request.userPresence- Presence flag to obtain additional info such as last active date.
-
queryMembers
@CheckResult() abstract Call<List<Member>> queryMembers(String cid, Integer offset, Integer limit, FilterObject filter, QuerySort<Member> sort, List<Member> members)
Query members of a channel.
- Parameters:
cid- CID of the Channel whose members we are querying.offset- Indicates how many items to exclude from the start of the result.limit- Indicates the maximum allowed number of items in the result.filter- Applied to online queries for advanced selection criteria.sort- The sort criteria applied to the result.
-
getUser
abstract StateFlow<User> getUser()
The current user on the chatDomain object
-
getOfflineEnabled
abstract Boolean getOfflineEnabled()
if offline is enabled
-
setOfflineEnabled
abstract Unit setOfflineEnabled(Boolean offlineEnabled)
if offline is enabled
-
getUserPresence
abstract Boolean getUserPresence()
if we want to track user presence
-
setUserPresence
abstract Unit setUserPresence(Boolean userPresence)
if we want to track user presence
-
getInitialized
abstract StateFlow<Boolean> getInitialized()
if the client connection has been initialized
-
getConnectionState
abstract StateFlow<ConnectionState> getConnectionState()
StateFlow<ConnectionState> that indicates if we are currently online, connecting of offline.
-
getTotalUnreadCount
abstract StateFlow<Integer> getTotalUnreadCount()
The total unread message count for the current user. Depending on your app you'll want to show this or the channelUnreadCount
-
getChannelUnreadCount
abstract StateFlow<Integer> getChannelUnreadCount()
the number of unread channels for the current user
-
getErrorEvents
abstract StateFlow<Event<ChatError>> getErrorEvents()
The error event state flow object is triggered when errors in the underlying components occur. The following example shows how to observe these errors
repo.errorEvent.collect { // create a toast }
-
getChannelMutes
abstract StateFlow<List<ChannelMute>> getChannelMutes()
List of channels you've muted
-
getRetryPolicy
abstract RetryPolicy getRetryPolicy()
The retry policy for retrying failed requests
-
getTypingUpdates
abstract StateFlow<TypingEvent> getTypingUpdates()
Updates about currently typing users in active channels. See TypingEvent.
-
-
-
-