Class ChannelClient

  • All Implemented Interfaces:

    
    public final class ChannelClient
    
                        

    Client for performing actions related to a specific channel.

    • Constructor Detail

    • Method Detail

      • getCid

         final String getCid()

        The channel id in the format of channelType:channelId.

      • get

         final Call<Channel> get(Integer messageLimit, Integer memberLimit, Boolean state)

        Gets the channel.

        Parameters:
        messageLimit - The number of messages to retrieve.
        memberLimit - The number of members to retrieve.
        state - Whether to retrieve the channel state or not.
      • create

        @CheckResult() final Call<Channel> create(List<String> memberIds, Map<String, Object> extraData)

        Creates the id-based channel.

        Parameters:
        memberIds - The list of members' ids.
        extraData - Map of key-value pairs that let you store extra data
        Returns:

        Executable async Call responsible for creating the channel.

      • sendMessage

        @CheckResult()@JvmOverloads() final Call<Message> sendMessage(Message message, Boolean isRetrying)

        Sends the message to the given channel with side effects if there is any plugin added in the client.

        Parameters:
        message - Message to send.
        isRetrying - True if this message is being retried.
        Returns:

        Executable async Call responsible for sending a message.

      • sendMessage

        @CheckResult()@JvmOverloads() final Call<Message> sendMessage(Message message)

        Sends the message to the given channel with side effects if there is any plugin added in the client.

        Parameters:
        message - Message to send.
        Returns:

        Executable async Call responsible for sending a message.

      • markThreadRead

        @CheckResult() final Call<Unit> markThreadRead(String threadId)

        Marks a given thread in the channel as read.

        Parameters:
        threadId - The ID of the thread to mark as read.
      • markThreadUnread

        @CheckResult() final Call<Unit> markThreadUnread(String threadId, String messageId)

        Marks a given thread in the channel starting from the given message as unread.

        Parameters:
        threadId - Id of the thread to mark as unread.
        messageId - Id of the message from where the thread should be marked as unread.
      • hide

        @CheckResult() final Call<Unit> hide(Boolean clearHistory)

        Hides the channel.

        Parameters:
        clearHistory - Boolean, if you want to clear the history of this channel or not.
        Returns:

        Executable async Call responsible for hiding a channel.

      • truncate

        @CheckResult()@JvmOverloads() final Call<Channel> truncate(Message systemMessage)

        Removes all of the messages of the channel but doesn't affect the channel data or members.

        Parameters:
        systemMessage - The system message object that will be shown in the channel.
        Returns:

        Executable async Call which completes with Result having data equal to the truncated channel if the channel was successfully truncated.

      • truncate

        @CheckResult()@JvmOverloads() final Call<Channel> truncate()

        Removes all of the messages of the channel but doesn't affect the channel data or members.

        Returns:

        Executable async Call which completes with Result having data equal to the truncated channel if the channel was successfully truncated.

      • sendFile

        @CheckResult()@JvmOverloads() final Call<UploadedFile> sendFile(File file, ProgressCallback callback)

        Uploads a file for the given channel. Progress can be accessed via callback.

        The Stream CDN imposes the following restrictions on file uploads:

        • The maximum file size is 100 MB

        Parameters:
        file - The file that needs to be uploaded.
        callback - The callback to track progress.
        Returns:

        Executable async Call which completes with Result containing an instance of UploadedFile if the file was successfully uploaded.

      • sendFile

        @CheckResult()@JvmOverloads() final Call<UploadedFile> sendFile(File file)

        Uploads a file for the given channel. Progress can be accessed via callback.

        The Stream CDN imposes the following restrictions on file uploads:

        • The maximum file size is 100 MB

        Parameters:
        file - The file that needs to be uploaded.
        Returns:

        Executable async Call which completes with Result containing an instance of UploadedFile if the file was successfully uploaded.

      • sendImage

        @CheckResult()@JvmOverloads() final Call<UploadedFile> sendImage(File file, ProgressCallback callback)

        Uploads an image for the given channel. Progress can be accessed via callback.

        The Stream CDN imposes the following restrictions on image uploads:

        • The maximum image size is 100 MB

        • Supported MIME types are listed in StreamCdnImageMimeTypes.SUPPORTED_IMAGE_MIME_TYPES

        Parameters:
        file - The image file that needs to be uploaded.
        callback - The callback to track progress.
        Returns:

        Executable async Call which completes with Result containing an instance of UploadedFile if the image was successfully uploaded.

      • sendImage

        @CheckResult()@JvmOverloads() final Call<UploadedFile> sendImage(File file)

        Uploads an image for the given channel. Progress can be accessed via callback.

        The Stream CDN imposes the following restrictions on image uploads:

        • The maximum image size is 100 MB

        • Supported MIME types are listed in StreamCdnImageMimeTypes.SUPPORTED_IMAGE_MIME_TYPES

        Parameters:
        file - The image file that needs to be uploaded.
        Returns:

        Executable async Call which completes with Result containing an instance of UploadedFile if the image was successfully uploaded.

      • deleteFile

        @CheckResult() final Call<Unit> deleteFile(String url)

        Deletes the file represented by url from the given channel.

        Parameters:
        url - The URL of the file to be deleted.
        Returns:

        Executable async Call responsible for deleting a file.

      • deleteImage

        @CheckResult() final Call<Unit> deleteImage(String url)

        Deletes the image represented by url from the given channel.

        Parameters:
        url - The URL of the image to be deleted.
        Returns:

        Executable async Call responsible for deleting an image.

      • sendReaction

        @CheckResult() final Call<Reaction> sendReaction(Reaction reaction, Boolean enforceUnique)

        Sends the reaction. Use enforceUnique parameter to specify whether the reaction should replace other reactions added by the current user.

        Parameters:
        reaction - The Reaction to send.
        enforceUnique - Flag to determine whether the reaction should replace other ones added by the current user.
        Returns:

        Executable async Call responsible for sending the reaction.

      • deleteReaction

        @CheckResult() final Call<Message> deleteReaction(String messageId, String reactionType)

        Deletes the reaction associated with the message with the given message id.

        Parameters:
        messageId - The id of the message to which reaction belongs.
        reactionType - The type of reaction.
        Returns:

        Executable async Call responsible for deleting the reaction.

      • update

        @CheckResult() final Call<Channel> update(Message message, Map<String, Object> extraData)

        Updates all of the channel data. Any data that is present on the channel and not included in a full update will be deleted.

        Parameters:
        message - The message object allowing you to show a system message in the channel.
        extraData - The updated channel extra data.
        Returns:

        Executable async Call responsible for updating channel data.

      • updatePartial

        @CheckResult() final Call<Channel> updatePartial(Map<String, Object> set, List<String> unset)

        Updates specific fields of channel data retaining the custom data fields which were set previously.

        Parameters:
        set - The key-value data which will be added to the existing channel data object.
        unset - The list of fields which will be removed from the existing channel data object.
      • partialUpdateMember

        @CheckResult() final Call<Member> partialUpdateMember(String userId, Map<String, Object> set, List<String> unset)

        Updates specific fields of custom data for a given member.

        Parameters:
        userId - The user id of the member to update.
        set - The key-value data to be updated in the member data.
        unset - The list of keys to be removed from the member data.
      • enableSlowMode

        @CheckResult() final Call<Channel> enableSlowMode(Integer cooldownTimeInSeconds)

        Enables slow mode for the channel. When slow mode is enabled, users can only send a message every cooldownTimeInSeconds time interval. The cooldownTimeInSeconds is specified in seconds, and should be between 1-120.

        Parameters:
        cooldownTimeInSeconds - The duration of the time interval users have to wait between messages.
        Returns:

        Executable async Call responsible for enabling slow mode.

      • disableSlowMode

        @CheckResult() final Call<Channel> disableSlowMode()

        Disables slow mode for the channel.

        Returns:

        Executable async Call responsible for disabling slow mode.

      • addMembers

        @CheckResult() final Call<Channel> addMembers(List<String> memberIds, Message systemMessage, Boolean hideHistory, Boolean skipPush)

        Adds members to a given channel.

        Parameters:
        memberIds - The list of the member ids to be added.
        systemMessage - The system message object that will be shown in the channel.
        hideHistory - Hides the history of the channel to the added member.
        skipPush - Skip sending push notifications.
        Returns:

        Executable async Call responsible for adding the members.

      • addMembers

        @CheckResult() final Call<Channel> addMembers(AddMembersParams params)

        Adds members with extra data to a given channel.

        Parameters:
        params - The AddMembersParams holding data about the members to be added.
        Returns:

        Executable async Call responsible for adding the members.

      • removeMembers

        @CheckResult() final Call<Channel> removeMembers(List<String> memberIds, Message systemMessage, Boolean skipPush)

        Removes members from a given channel.

        Parameters:
        memberIds - The list of the member ids to be removed.
        systemMessage - The system message object that will be shown in the channel.
        skipPush - Skip sending push notifications.
        Returns:

        Executable async Call responsible for removing the members.

      • inviteMembers

        @CheckResult() final Call<Channel> inviteMembers(List<String> memberIds, Message systemMessage, Boolean skipPush)

        Invites members to a given channel.

        Parameters:
        memberIds - The list of the member ids to be invited.
        systemMessage - The system message object that will be shown in the channel.
        skipPush - Skip sending push notifications.
        Returns:

        Executable async Call responsible for inviting the members.

      • mute

        @JvmOverloads()@CheckResult() final Call<Unit> mute(Integer expiration)

        Mutes a channel for the current user. Messages added to the channel will not trigger push notifications, and will not change the unread count for the users that muted it. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set an expiration time. Triggers notification.channel_mutes_updated event.

        Parameters:
        expiration - The duration of mute in millis.
        Returns:

        Executable async Call responsible for muting a channel.

      • mute

        @JvmOverloads()@CheckResult() final Call<Unit> mute()

        Mutes a channel for the current user. Messages added to the channel will not trigger push notifications, and will not change the unread count for the users that muted it. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set an expiration time. Triggers notification.channel_mutes_updated event.

        Returns:

        Executable async Call responsible for muting a channel.

      • unmute

        @CheckResult() final Call<Unit> unmute()

        Unmutes a channel for the current user. Triggers notification.channel_mutes_updated event.

        Returns:

        Executable async Call responsible for unmuting a channel.

      • muteUser

        @JvmOverloads()@CheckResult() final Call<Mute> muteUser(String userId, Integer timeout)

        Mutes a user. Messages from muted users will not trigger push notifications. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set a mute timeout. Triggers notification.mutes_updated event.

        Parameters:
        userId - The user id to mute.
        timeout - The timeout in minutes until the mute is expired.
        Returns:

        Executable async Call responsible for muting a user.

      • muteUser

        @JvmOverloads()@CheckResult() final Call<Mute> muteUser(String userId)

        Mutes a user. Messages from muted users will not trigger push notifications. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set a mute timeout. Triggers notification.mutes_updated event.

        Parameters:
        userId - The user id to mute.
        Returns:

        Executable async Call responsible for muting a user.

      • unmuteUser

        @CheckResult() final Call<Unit> unmuteUser(String userId)

        Unmutes a previously muted user. Triggers notification.mutes_updated event.

        Parameters:
        userId - The user id to unmute.
        Returns:

        Executable async Call responsible for unmuting a user.

      • keystroke

        @CheckResult()@JvmOverloads() final Call<ChatEvent> keystroke(String parentId)

        Sends a start typing event EventType.TYPING_START in this channel to the server.

        Parameters:
        parentId - Set this field to message.id to indicate that typing event is happening in a thread.
        Returns:

        Executable async Call which completes with Result having ChatEvent data if successful or Error if fails.

      • keystroke

        @CheckResult()@JvmOverloads() final Call<ChatEvent> keystroke()

        Sends a start typing event EventType.TYPING_START in this channel to the server.

        Returns:

        Executable async Call which completes with Result having ChatEvent data if successful or Error if fails.

      • stopTyping

        @CheckResult()@JvmOverloads() final Call<ChatEvent> stopTyping(String parentId)

        Sends a stop typing event EventType.TYPING_STOP in this channel to the server.

        Parameters:
        parentId - Set this field to message.id to indicate that typing event is happening in a thread.
        Returns:

        Executable async Call which completes with Result having ChatEvent data if successful or Error if fails.

      • stopTyping

        @CheckResult()@JvmOverloads() final Call<ChatEvent> stopTyping()

        Sends a stop typing event EventType.TYPING_STOP in this channel to the server.

        Returns:

        Executable async Call which completes with Result having ChatEvent data if successful or Error if fails.

      • sendEvent

        @CheckResult() final Call<ChatEvent> sendEvent(String eventType, Map<Object, Object> extraData)

        Sends an event to all users watching the channel.

        Parameters:
        eventType - The event name.
        extraData - The event payload.
        Returns:

        Executable async Call responsible for sending an event.

      • queryMembers

        @CheckResult() final Call<List<Member>> queryMembers(Integer offset, Integer limit, FilterObject filter, QuerySorter<Member> sort, List<Member> members)

        Queries members for this channel.

        Parameters:
        offset - Offset limit.
        limit - Number of members to fetch.
        filter - FilterObject to filter members of certain type.
        sort - Sort the list of members.
        members - List of members to search in distinct channels.
        Returns:

        Call with a list of members or an error.

      • getMessagesWithAttachments

        @CheckResult() final Call<List<Message>> getMessagesWithAttachments(Integer offset, Integer limit, List<String> types)

        Returns a Call with messages that contain at least one desired type attachment but not necessarily all of them will have a specified type.

        Parameters:
        offset - The messages offset.
        limit - Max limit messages to be fetched.
        types - Desired attachment's types list.
      • getPinnedMessages

        @CheckResult() final Call<List<Message>> getPinnedMessages(Integer limit, QuerySorter<Message> sort, PinnedMessagesPagination pagination)

        Returns a list of messages pinned in the channel. You can sort the list by specifying sort parameter. Keep in mind that for now we only support sorting by Message.pinnedAt. The list can be paginated in a few different ways using limit and pagination.

        Parameters:
        limit - Max limit of messages to be fetched.
        sort - Parameter by which we sort the messages.
        pagination - Provides different options for pagination.
        Returns:

        Executable async Call responsible for getting pinned messages.

      • pin

        @CheckResult() final Call<Member> pin()

        Pins the channel for the current user.

        Returns:

        Executable async Call responsible for pinning the channel.

      • unpin

        @CheckResult() final Call<Member> unpin()

        Unpins the channel for the current user.

        Returns:

        Executable async Call responsible for unpinning the channel.

      • archive

        @CheckResult() final Call<Member> archive()

        Archives the channel for the current user.

        Returns:

        Executable async Call responsible for archiving the channel.

      • unarchive

        @CheckResult() final Call<Member> unarchive()

        Un-archives the channel for the current user.

        Returns:

        Executable async Call responsible for un-archiving the channel.