Class Message
-
- All Implemented Interfaces:
public final class MessageMessage envelope class.
Contains general message properties (ID, sender, timestamp, etc.) and the message content body content.
General fields (ID, sender, timestamp, etc.) are stored in Message.
Specific content (text, image, etc.) is stored in content as a MessageContent subclass.
val message: Message = ... when (val content = message.content) { is TextMessage -> println("Text: ${content.text}") is ImageMessage -> println("Image: ${content.remoteUrl}") is FileMessage -> println("File: ${content.name}") }
-
-
Field Summary
Fields Modifier and Type Field Description private final ChannelIdentifierchannelIdentifierprivate final BooleanisCountedprivate final BooleanisPersistedprivate final BooleanisStatusMessageprivate final IntegerclientIdprivate MessageDirectiondirectionprivate StringsenderUserIdprivate MessageReceivedStatusInforeceivedStatusInfoprivate SentStatussentStatusprivate LongsentTimeprivate final StringmessageTypeprivate MessageContentcontentprivate final StringmessageIdprivate Map<String, String>metadataprivate final BooleanhasChangedprivate MessageModifyInfomodifyInfoprivate BooleanneedReceiptprivate final BooleansentReceiptprivate List<String>directedUserIdsprivate final BooleandisableNotificationprivate BooleandisableUpdateLastMessage
-
Method Summary
Modifier and Type Method Description final ChannelIdentifiergetChannelIdentifier()Channel identifier containing channel type and channel ID. final BooleanisCounted()Whether this message is counted for unread count. final BooleanisPersisted()Whether this message is persisted in local storage. final BooleanisStatusMessage()Whether this is a status-only message (not stored or counted). final IntegergetClientId()Auto-increment ID in the local database message table (client-side local ID). final MessageDirectiongetDirection()Message direction (send / receive). final UnitsetDirection(MessageDirection direction)Message direction (send / receive). final StringgetSenderUserId()Sender user ID. final UnitsetSenderUserId(String senderUserId)Sender user ID. final MessageReceivedStatusInfogetReceivedStatusInfo()Message received status info. final UnitsetReceivedStatusInfo(MessageReceivedStatusInfo receivedStatusInfo)Message received status info. final SentStatusgetSentStatus()Message sending status. final UnitsetSentStatus(SentStatus sentStatus)Message sending status. final LonggetSentTime()Message sent time (Unix timestamp in milliseconds, server time). final UnitsetSentTime(Long sentTime)Message sent time (Unix timestamp in milliseconds, server time). final StringgetMessageType()Message type identifier. final MessageContentgetContent()Message content body. final UnitsetContent(MessageContent content)Message content body. final StringgetMessageId()Server-side unique message ID (globally unique within the same app). final Map<String, String>getMetadata()Message metadata in key-value format, supports remote sync. final UnitsetMetadata(Map<String, String> metadata)Message metadata in key-value format, supports remote sync. final BooleangetHasChanged()Whether the message has been modified (community channel messages only). final MessageModifyInfogetModifyInfo()Message modification info. final UnitsetModifyInfo(MessageModifyInfo modifyInfo)Message modification info. final BooleangetNeedReceipt()Whether this message requires a read receipt. final UnitsetNeedReceipt(Boolean needReceipt)Whether this message requires a read receipt. final BooleangetSentReceipt()Whether a read receipt has been sent for this message. final List<String>getDirectedUserIds()Directed user ID list (only effective for group / community channels; null for direct channels). final UnitsetDirectedUserIds(List<String> directedUserIds)Directed user ID list (only effective for group / community channels; null for direct channels). final BooleangetDisableNotification()Whether push notification is disabled for this message. final BooleangetDisableUpdateLastMessage()Whether to prevent this message from updating the channel's latest message. final UnitsetDisableUpdateLastMessage(Boolean disableUpdateLastMessage)Whether to prevent this message from updating the channel's latest message. final UnitsetReceivedStatusInfo(MessageReceivedStatusInfo receivedStatusInfo, OperationHandler<Boolean> handler)Sets the received status of this message. final UnitsetMetadata(Map<String, String> metadata, ErrorHandler handler)Updates message metadata. final UnitdeleteMetadata(List<String> keys, ErrorHandler handler)Removes message metadata by keys. final UnitrequestSpeechToText(ErrorHandler handler)Requests speech-to-text conversion for a voice message. final UnitsetSpeechToTextVisible(Boolean isVisible, ErrorHandler handler)Sets the visibility of the speech-to-text result. final UnitdownloadMedia(DownloadMediaMessageHandler handler)Downloads the media file attached to this message. final UnitrequestStreamMessage(ErrorHandler handler)Requests stream message content pulling. final UnitcancelDownloadingMedia(ErrorHandler handler)Cancels the ongoing media download for this message. final UnitpauseDownloadingMedia(ErrorHandler handler)Pauses the ongoing media download for this message. StringtoString()-
-
Method Detail
-
getChannelIdentifier
final ChannelIdentifier getChannelIdentifier()
Channel identifier containing channel type and channel ID.
-
isCounted
final Boolean isCounted()
Whether this message is counted for unread count.
-
isPersisted
final Boolean isPersisted()
Whether this message is persisted in local storage.
-
isStatusMessage
final Boolean isStatusMessage()
Whether this is a status-only message (not stored or counted).
-
getClientId
final Integer getClientId()
Auto-increment ID in the local database message table (client-side local ID).
-
getDirection
final MessageDirection getDirection()
Message direction (send / receive).
-
setDirection
final Unit setDirection(MessageDirection direction)
Message direction (send / receive).
-
getSenderUserId
final String getSenderUserId()
Sender user ID.
-
setSenderUserId
final Unit setSenderUserId(String senderUserId)
Sender user ID.
-
getReceivedStatusInfo
final MessageReceivedStatusInfo getReceivedStatusInfo()
Message received status info.
-
setReceivedStatusInfo
final Unit setReceivedStatusInfo(MessageReceivedStatusInfo receivedStatusInfo)
Message received status info.
-
getSentStatus
final SentStatus getSentStatus()
Message sending status.
-
setSentStatus
final Unit setSentStatus(SentStatus sentStatus)
Message sending status.
-
getSentTime
final Long getSentTime()
Message sent time (Unix timestamp in milliseconds, server time).
-
setSentTime
final Unit setSentTime(Long sentTime)
Message sent time (Unix timestamp in milliseconds, server time).
-
getMessageType
final String getMessageType()
Message type identifier. See ai.nexconn.chat.message.model.MessageType for built-in types.
-
getContent
final MessageContent getContent()
Message content body.
-
setContent
final Unit setContent(MessageContent content)
Message content body.
-
getMessageId
final String getMessageId()
Server-side unique message ID (globally unique within the same app).
-
getMetadata
final Map<String, String> getMetadata()
Message metadata in key-value format, supports remote sync.
-
setMetadata
final Unit setMetadata(Map<String, String> metadata)
Message metadata in key-value format, supports remote sync.
-
getHasChanged
final Boolean getHasChanged()
Whether the message has been modified (community channel messages only).
-
getModifyInfo
final MessageModifyInfo getModifyInfo()
Message modification info.
-
setModifyInfo
final Unit setModifyInfo(MessageModifyInfo modifyInfo)
Message modification info.
-
getNeedReceipt
final Boolean getNeedReceipt()
Whether this message requires a read receipt.
-
setNeedReceipt
final Unit setNeedReceipt(Boolean needReceipt)
Whether this message requires a read receipt.
-
getSentReceipt
final Boolean getSentReceipt()
Whether a read receipt has been sent for this message.
-
getDirectedUserIds
final List<String> getDirectedUserIds()
Directed user ID list (only effective for group / community channels; null for direct channels).
-
setDirectedUserIds
final Unit setDirectedUserIds(List<String> directedUserIds)
Directed user ID list (only effective for group / community channels; null for direct channels).
-
getDisableNotification
final Boolean getDisableNotification()
Whether push notification is disabled for this message.
-
getDisableUpdateLastMessage
final Boolean getDisableUpdateLastMessage()
Whether to prevent this message from updating the channel's latest message.
-
setDisableUpdateLastMessage
final Unit setDisableUpdateLastMessage(Boolean disableUpdateLastMessage)
Whether to prevent this message from updating the channel's latest message.
-
setReceivedStatusInfo
final Unit setReceivedStatusInfo(MessageReceivedStatusInfo receivedStatusInfo, OperationHandler<Boolean> handler)
Sets the received status of this message.
Updates the message's received status in the local database.
val status = ReceivedStatus() status.setRead() status.setListened() message.setReceivedStatusInfo(status) { success, error -> if (error == null) { // Status updated } }- Parameters:
handler- Callback returning true on success
-
setMetadata
final Unit setMetadata(Map<String, String> metadata, ErrorHandler handler)
Updates message metadata.
Sets or updates key-value metadata for this message, with remote sync support.
message.setMetadata(mapOf("read_count" to "10", "liked" to "true")) { error -> if (error == null) { // Updated successfully } }- Parameters:
metadata- Key-value pairs to update; existing keys will be overwrittenhandler- Operation result callback; error is null on success
-
deleteMetadata
final Unit deleteMetadata(List<String> keys, ErrorHandler handler)
Removes message metadata by keys.
Deletes the specified keys from this message's metadata, with remote sync support.
message.removeMetadata(listOf("read_count", "liked")) { error -> if (error == null) { // Removed successfully } }- Parameters:
keys- List of metadata keys to removehandler- Operation result callback; error is null on success
-
requestSpeechToText
final Unit requestSpeechToText(ErrorHandler handler)
Requests speech-to-text conversion for a voice message.
After the conversion completes, the result is delivered via ai.nexconn.chat.handler.MessageHandler.onSpeechToTextCompleted.
message.requestSpeechToText { error -> if (error == null) { // Request sent; awaiting completion callback } }- Parameters:
handler- Operation result callback; error is null on success
-
setSpeechToTextVisible
final Unit setSpeechToTextVisible(Boolean isVisible, ErrorHandler handler)
Sets the visibility of the speech-to-text result.
Controls whether the speech-to-text result is displayed in the UI. The visibility state is persisted to the local database.
message.setSpeechToTextVisible(true) { error -> if (error == null) { // Set successfully } }- Parameters:
isVisible- Whether the speech-to-text result should be visiblehandler- Operation result callback; error is null on success
-
downloadMedia
final Unit downloadMedia(DownloadMediaMessageHandler handler)
Downloads the media file attached to this message.
Applies to media messages (image, voice, video, file, etc.). Download progress and result are delivered via DownloadMediaMessageHandler.
message.downloadMedia(object : DownloadMediaMessageHandler { override fun onSuccess(message: Message) { /* Download succeeded */} override fun onProgress(message: Message, progress: Int) { /* Progress updated */} override fun onError(message: Message, error: NCError) { /* Download failed */} override fun onCanceled(message: Message) { /* Download cancelled */} })- Parameters:
handler- Download callback
-
requestStreamMessage
final Unit requestStreamMessage(ErrorHandler handler)
Requests stream message content pulling.
Initiates a stream pull for this message. The incremental data and completion are delivered via ai.nexconn.chat.handler.MessageHandler callbacks:
ai.nexconn.chat.handler.MessageHandler.onStreamMessageRequestInit
ai.nexconn.chat.handler.MessageHandler.onStreamMessageRequestDelta
ai.nexconn.chat.handler.MessageHandler.onStreamMessageRequestComplete
message.requestStreamMessage { error -> if (error == null) { // Request sent successfully, waiting for stream data callbacks } }- Parameters:
handler- Operation result callback; error is null on success
-
cancelDownloadingMedia
final Unit cancelDownloadingMedia(ErrorHandler handler)
Cancels the ongoing media download for this message.
message.cancelDownloadingMedia { error -> if (error == null) { // Cancelled successfully } }- Parameters:
handler- Operation result callback; error is null on success
-
pauseDownloadingMedia
final Unit pauseDownloadingMedia(ErrorHandler handler)
Pauses the ongoing media download for this message.
message.pauseDownloadingMedia { error -> if (error == null) { // Paused successfully } }- Parameters:
handler- Operation result callback; error is null on success
-
toString
String toString()
-
-
-
-