Class BaseChannel

  • All Implemented Interfaces:

    
    public class BaseChannel
    
                        

    Base class for all channel types.

    Contains common channel properties and methods for message querying, unread count management, and channel operations.

    Inheritance hierarchy:

    BaseChannel
    ├── DirectChannel   (1:1 private chat)
    ├── GroupChannel     (group chat)
    ├── SystemChannel    (system notifications)
    ├── OpenChannel      (open channel)
    └── CommunityChannel (community)
    • Constructor Detail

    • Method Detail

      • getChannelId

         final String getChannelId()

        Channel unique identifier

      • isPinned

         final Boolean isPinned()

        Whether this channel is pinned to the top.

      • getOperationTime

         final Long getOperationTime()

        Channel operation timestamp in milliseconds.

        Initially equals the latest message's sent time. Operations such as pinning will update this timestamp. Used as the cursor for paginated channel list queries.

      • getDraft

         final String getDraft()

        Text message draft content for this channel.

      • getLatestMessage

         final Message getLatestMessage()

        The latest message in this channel.

        Contains full message details including content, sender, and sent time.

      • getMentionedCount

         final Integer getMentionedCount()

        Unread count of mentioned messages (including @all).

      • getMentionedMeCount

         final Integer getMentionedMeCount()

        Unread count of messages that specifically mention the current user.

      • getIncludeRobot

         final Boolean getIncludeRobot()

        Whether this channel contains a robot/bot user.

      • pin

         Unit pin(PinParams params, OperationHandler<Boolean> handler)

        Pins this channel to the top of the channel list.

        Parameters:
        params - Pin parameters
        handler - Callback returning the operation result
      • unpin

         Unit unpin(OperationHandler<Boolean> handler)

        Unpins this channel from the top of the channel list.

        Parameters:
        handler - Callback returning the operation result
      • delete

         final Unit delete(OperationHandler<Boolean> handler)

        Deletes this channel locally.

        This does not delete messages within the channel. If new messages arrive, the channel will reappear in the list.

        Parameters:
        handler - Callback returning the operation result
      • clearUnreadCount

         Unit clearUnreadCount(OperationHandler<Boolean> handler)

        Clears the unread message count for this channel.

        Parameters:
        handler - Callback returning the operation result
      • deleteTags

         final Unit deleteTags(List<String> tagIds, ErrorHandler handler)

        Removes tags from this channel.

        Parameters:
        tagIds - List of tag IDs to remove
        handler - Error callback; null error indicates success
      • saveDraft

         final Unit saveDraft(String draft, OperationHandler<Boolean> handler)

        Saves a text message draft for this channel.

        Parameters:
        draft - The draft content to save
        handler - Callback returning the operation result
      • clearDraft

         final Unit clearDraft(OperationHandler<Boolean> handler)

        Clears the text message draft for this channel.

        Parameters:
        handler - Callback returning the operation result
      • sendMessage

         final Unit sendMessage(SendMessageParams params, SendMessageHandler handler)

        Sends a non-media message in this channel (e.g., text, location).

        Note: Cannot send more than 5 messages per second.

        Parameters:
        params - Send message parameters containing the message and optional push config
        handler - Callback for tracking the message sending lifecycle
      • sendMediaMessage

         final Unit sendMediaMessage(SendMediaMessageParams params, SendMediaMessageHandler handler)

        Sends a media message in this channel (e.g., image, video, file).

        Parameters:
        params - Send media message parameters containing the message and optional push config
        handler - Callback for tracking the media message sending lifecycle, including upload progress
      • insertMessages

         final Unit insertMessages(List<InsertMessageItem> params, OperationHandler<Boolean> handler)

        Batch inserts messages into the local database.

        Messages are inserted locally only and are not sent to the server. The channel info (channelType, channelId) is taken from this channel instance.

        Parameters:
        params - List of message items to insert
        handler - Callback returning true on success
      • deleteMessagesForMe

         final Unit deleteMessagesForMe(List<Message> messages, ErrorHandler handler)

        Deletes messages locally (for the current user only).

        Parameters:
        messages - List of messages to delete
        handler - Error callback; null error indicates success
      • deleteLocalMessages

         final Unit deleteLocalMessages(List<String> messageClientIds, OperationHandler<Boolean> handler)

        Deletes local messages by their client IDs.

        Parameters:
        messageClientIds - List of message client IDs to delete
        handler - Callback returning true on success
      • deleteMessagesForMeByTimestamp

         Unit deleteMessagesForMeByTimestamp(DeleteMessagesForMeByTimestampParams params, ErrorHandler handler)

        Deletes messages before the specified timestamp (for the current user).

        The operation policy determines whether messages are deleted locally only or both locally and remotely.

        Parameters:
        params - Parameters including the timestamp and operation policy
        handler - Error callback; null error indicates success
      • getMessagesAroundTime

         final Unit getMessagesAroundTime(GetMessagesAroundTimeParams params, OperationHandler<List<Message>> handler)

        Gets messages around a given sent timestamp.

        Returns messages both before and after the specified time, sorted chronologically.

        Parameters:
        params - Parameters including the sent time and the count of messages before/after
        handler - Callback returning the message list on success
      • sendReadReceiptResponse

         final Unit sendReadReceiptResponse(List<String> messageIds, ErrorHandler handler)

        Sends a read receipt response for the specified messages.

        Parameters:
        messageIds - List of message IDs to acknowledge
        handler - Error callback; null error indicates success
      • getMessageReadReceiptInfo

         final Unit getMessageReadReceiptInfo(List<String> messageIds, OperationHandler<List<ReadReceiptInfo>> handler)

        Gets read receipt info for the specified messages.

        Parameters:
        messageIds - List of message IDs to query
        handler - Callback returning the read receipt info list on success
      • reload

         final Unit reload(OperationHandler<BaseChannel> handler)

        Reloads channel data from the local database.

        Fetches the latest information for this channel and returns a new BaseChannel object.

        Parameters:
        handler - Callback returning the latest channel object on success
      • equals

         Boolean equals(Object other)