Package 

Interface ChatDomain


  • 
    public interface ChatDomain
    
                        

    The ChatDomain is the main entry point for all flow & offline operations on chat

    • Method Detail

      • createDistinctChannel

         abstract Call<Channel> createDistinctChannel(String channelType, List<String> members, Map<String, Object> extraData)

        Returns a distinct channel based on its' members. If such channel exists returns existing one, otherwise creates a new.

        Parameters:
        channelType - String represents channel type.
        members - List of members' id.
        extraData - Map object with custom fields and additional data.
      • replayEventsForActiveChannels

         abstract Call<List<ChatEvent>> replayEventsForActiveChannels(String cid)

        Adds the provided channel to the active channels and replays events for all active channels

      • watchChannel

         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

         abstract Call<QueryChannelsController> queryChannels(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit)

        Queries offline storage and the API for channels matching the filter Returns a queryChannelsController

        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
      • getThread

         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

         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

         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

         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

         abstract Call<List<Channel>> queryChannelsLoadMore(FilterObject filter, QuerySort<Channel> sort, Integer limit, Integer messageLimit)

        Load more channels for this query

        Parameters:
        filter - the filter for querying channels, see https://getstream.io/chat/docs/query_channels/?
        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 chanel
      • queryChannelsLoadMore

         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/?
        sort - the sort for the channels, by default will sort on last_message_at
        messageLimit - how many messages to fetch per chanel
      • queryChannelsLoadMore

         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/?
        sort - the sort for the channels, by default will sort on last_message_at
      • threadLoadMore

         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

         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

         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
      • sendMessage

         abstract Call<Message> sendMessage(Message message, Function2<Attachment, File, Attachment> attachmentTransformer)

        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

         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

         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

         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

         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

         abstract Call<Message> deleteMessage(Message message)

        Deletes the specified message, request is retried according to the retry policy specified on the chatDomain

        Parameters:
        message - the message to mark as deleted
      • sendReaction

         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

         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

         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 to message.id to indicate that typing event is happening in a thread
      • stopTyping

         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 to message.id to indicate that typing event is happening in a thread
      • markRead

         abstract Call<Boolean> markRead(String cid)

        Marks all messages of the specified channel as read

        Parameters:
        cid - : the full channel id i.
      • markAllRead

         abstract Call<Boolean> markAllRead()

        Marks all messages on a channel as read.

      • hideChannel

         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

         abstract Call<Unit> showChannel(String cid)

        Shows a channel that was previously hidden

        Parameters:
        cid - : the full channel id i.
      • leaveChannel

         abstract Call<Unit> leaveChannel(String cid)

        Leaves the channel with the specified id

        Parameters:
        cid - : the full channel id i.
      • deleteChannel

         abstract Call<Unit> deleteChannel(String cid)

        Deletes the channel with the specified id

        Parameters:
        cid - : the full channel id i.
      • setMessageForReply

         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

         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

         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

         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
      • getCurrentUser

         abstract User getCurrentUser()

        Unsafe property that represent the current user. This property could be not initialized. You should subscribe to ChatDomain.user instead

      • setCurrentUser

         abstract Unit setCurrentUser(@Deprecated(message = This property is not NPE-Safe, it could be not initialized. You should subscribe to [ChatDomain.user] instead, level = DeprecationLevel.WARNING) User currentUser)

        Unsafe property that represent the current user. This property could be not initialized. You should subscribe to ChatDomain.user instead

      • getUser

         abstract StateFlow<User> getUser()

        The current user on the chatDomain object

      • getInitialized

         abstract StateFlow<Boolean> getInitialized()

        if the client connection has been initialized

      • getOnline

         abstract StateFlow<Boolean> getOnline()

        StateFlow<Boolean> that indicates if we are currently online

      • 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

      • 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 }

      • getMuted

         abstract StateFlow<List<Mute>> getMuted()

        list of users that you've muted

      • getBanned

         abstract StateFlow<Boolean> getBanned()

        if the current user is banned or not

      • getTypingUpdates

         abstract StateFlow<TypingEvent> getTypingUpdates()

        Updates about currently typing users in active channels. See TypingEvent.