Class BaseChannel
-
- All Implemented Interfaces:
public class BaseChannelBase 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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classBaseChannel.Companion
-
Field Summary
Fields Modifier and Type Field Description private final StringchannelIdprivate final ChannelTypechannelTypeprivate final IntegerunreadCountprivate final BooleanisPinnedprivate final LongoperationTimeprivate final Stringdraftprivate final MessagelatestMessageprivate final IntegermentionedCountprivate final IntegermentionedMeCountprivate final ChannelNoDisturbLevelnoDisturbLevelprivate final TranslateStrategytranslateStrategyprivate final BooleanincludeRobotprivate final EditedMessageDrafteditedMessageDraftpublic final static BaseChannel.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final StringgetChannelId()Channel unique identifier final ChannelTypegetChannelType()Channel type final IntegergetUnreadCount()Unread message count. final BooleanisPinned()Whether this channel is pinned to the top. final LonggetOperationTime()Channel operation timestamp in milliseconds. final StringgetDraft()Text message draft content for this channel. final MessagegetLatestMessage()The latest message in this channel. final IntegergetMentionedCount()Unread count of mentioned messages (including @all). final IntegergetMentionedMeCount()Unread count of messages that specifically mention the current user. final ChannelNoDisturbLevelgetNoDisturbLevel()Channel message push notification level. final TranslateStrategygetTranslateStrategy()Channel translation strategy. final BooleangetIncludeRobot()Whether this channel contains a robot/bot user. final EditedMessageDraftgetEditedMessageDraft()Draft info for an edited message. Unitpin(PinParams params, OperationHandler<Boolean> handler)Pins this channel to the top of the channel list. Unitunpin(OperationHandler<Boolean> handler)Unpins this channel from the top of the channel list. final Unitdelete(OperationHandler<Boolean> handler)Deletes this channel locally. final UnitsetNoDisturbLevel(ChannelNoDisturbLevel level, ErrorHandler handler)Sets the notification (do-not-disturb) level for this channel. UnitclearUnreadCount(OperationHandler<Boolean> handler)Clears the unread message count for this channel. final UnitgetFirstUnreadMessage(OperationHandler<Message> handler)Gets the first unread message in this channel. UnitgetUnreadMentionedMessages(OperationHandler<List<Message>> handler)Gets unread mentioned messages in this channel. final UnitgetTags(OperationHandler<List<ChannelTagInfo>> handler)Gets all tags associated with this channel. final UnitdeleteTags(List<String> tagIds, ErrorHandler handler)Removes tags from this channel. final UnitsaveDraft(String draft, OperationHandler<Boolean> handler)Saves a text message draft for this channel. final UnitclearDraft(OperationHandler<Boolean> handler)Clears the text message draft for this channel. final UnitsendMessage(SendMessageParams params, SendMessageHandler handler)Sends a non-media message in this channel (e.g., text, location). final UnitsendMediaMessage(SendMediaMessageParams params, SendMediaMessageHandler handler)Sends a media message in this channel (e.g., image, video, file). final UnitinsertMessages(List<InsertMessageItem> params, OperationHandler<Boolean> handler)Batch inserts messages into the local database. final UnitmodifyMessage(ModifyMessageParams params, OperationHandler<Message> handler)Modifies a sent message. final UnitdeleteMessagesForMe(List<Message> messages, ErrorHandler handler)Deletes messages locally (for the current user only). final UnitdeleteLocalMessages(List<String> messageClientIds, OperationHandler<Boolean> handler)Deletes local messages by their client IDs. final UnitdeleteMessageForAll(Message message, OperationHandler<Message> handler)Deletes a message for all users (recall). UnitdeleteMessagesForMeByTimestamp(DeleteMessagesForMeByTimestampParams params, ErrorHandler handler)Deletes messages before the specified timestamp (for the current user). final UnitgetMessagesAroundTime(GetMessagesAroundTimeParams params, OperationHandler<List<Message>> handler)Gets messages around a given sent timestamp. final UnitsendReadReceiptResponse(List<String> messageIds, ErrorHandler handler)Sends a read receipt response for the specified messages. final UnitgetMessageReadReceiptInfo(List<String> messageIds, OperationHandler<List<ReadReceiptInfo>> handler)Gets read receipt info for the specified messages. final UnitgetMessagesReadReceiptByUsers(GetMessagesReadReceiptByUsersParams params, OperationHandler<ReadReceiptUsersResult> handler)Gets read receipt details grouped by users. final Unitreload(OperationHandler<BaseChannel> handler)Reloads channel data from the local database. Booleanequals(Object other)IntegerhashCode()StringtoString()-
-
Method Detail
-
getChannelId
final String getChannelId()
Channel unique identifier
-
getChannelType
final ChannelType getChannelType()
Channel type
-
getUnreadCount
final Integer getUnreadCount()
Unread message count.
-
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.
-
getNoDisturbLevel
final ChannelNoDisturbLevel getNoDisturbLevel()
Channel message push notification level.
-
getTranslateStrategy
final TranslateStrategy getTranslateStrategy()
Channel translation strategy.
-
getIncludeRobot
final Boolean getIncludeRobot()
Whether this channel contains a robot/bot user.
-
getEditedMessageDraft
final EditedMessageDraft getEditedMessageDraft()
Draft info for an edited message.
Stores the draft content when the user is editing a previously sent message.
-
pin
Unit pin(PinParams params, OperationHandler<Boolean> handler)
Pins this channel to the top of the channel list.
- Parameters:
params- Pin parametershandler- 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
-
setNoDisturbLevel
final Unit setNoDisturbLevel(ChannelNoDisturbLevel level, ErrorHandler handler)
Sets the notification (do-not-disturb) level for this channel.
- Parameters:
level- The notification level to sethandler- Error callback;nullerror indicates success
-
clearUnreadCount
Unit clearUnreadCount(OperationHandler<Boolean> handler)
Clears the unread message count for this channel.
- Parameters:
handler- Callback returning the operation result
-
getFirstUnreadMessage
final Unit getFirstUnreadMessage(OperationHandler<Message> handler)
Gets the first unread message in this channel.
- Parameters:
handler- Callback returning the first unread message on success
-
getUnreadMentionedMessages
Unit getUnreadMentionedMessages(OperationHandler<List<Message>> handler)
Gets unread mentioned messages in this channel.
- Parameters:
handler- Callback returning the list of unread mentioned messages on success
-
getTags
final Unit getTags(OperationHandler<List<ChannelTagInfo>> handler)
Gets all tags associated with this channel.
- Parameters:
handler- Callback returning the list of channel tag info on success
-
deleteTags
final Unit deleteTags(List<String> tagIds, ErrorHandler handler)
Removes tags from this channel.
- Parameters:
tagIds- List of tag IDs to removehandler- Error callback;nullerror 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 savehandler- 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 confighandler- 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 confighandler- 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 inserthandler- Callback returningtrueon success
-
modifyMessage
final Unit modifyMessage(ModifyMessageParams params, OperationHandler<Message> handler)
Modifies a sent message.
- Parameters:
params- Modify message parametershandler- Callback returning the updated message 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 deletehandler- Error callback;nullerror 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 deletehandler- Callback returningtrueon success
-
deleteMessageForAll
final Unit deleteMessageForAll(Message message, OperationHandler<Message> handler)
Deletes a message for all users (recall).
- Parameters:
message- The message to recallhandler- Callback returning the recalled message 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 policyhandler- Error callback;nullerror 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/afterhandler- 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 acknowledgehandler- Error callback;nullerror 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 queryhandler- Callback returning the read receipt info list on success
-
getMessagesReadReceiptByUsers
final Unit getMessagesReadReceiptByUsers(GetMessagesReadReceiptByUsersParams params, OperationHandler<ReadReceiptUsersResult> handler)
Gets read receipt details grouped by users.
- Parameters:
params- Query parameters including message ID and user ID listhandler- Callback returning the read receipt users result 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)
-
hashCode
Integer hashCode()
-
toString
String toString()
-
-
-
-