Class Message
-
- All Implemented Interfaces:
public class Message
The message object that contains and stores the message information received by the client, corresponding to the message in the chat UI.
rongcloud
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
Message.MessageDirection
Message Direction Enumeration.**
public enum
Message.SentStatus
The status of the sent message.
public class
Message.ReceivedStatus
The status of the received message.
It is a bitwise-marked enumeration that supports bitwise operations.
-
Field Summary
Fields Modifier and Type Field Description public ConversationType
conversationType
public String
targetId
public String
channelId
public int
messageId
public Message.MessageDirection
messageDirection
public String
senderUserId
public Message.ReceivedStatus
receivedStatus
public Message.SentStatus
sentStatus
public long
receivedTime
public long
sentTime
public long
readTime
public String
objectName
public MessageContent
content
public String
extra
public ReadReceiptInfo
readReceiptInfo
public ReadReceiptInfoV4
readReceiptInfoV4
public MessageConfig
messageConfig
public MessagePushConfig
messagePushConfig
public boolean
isOffline
public Map<String, String>
expansion
public List<String>
directedUserIds
public boolean
isEmptyContent
public final static Creator<Message>
CREATOR
-
Method Summary
Modifier and Type Method Description ConversationType
getConversationType()
Retrieves the conversation type. void
setConversationType(ConversationType conversationType)
Sets the conversation type. String
getTargetId()
Retrieves the target ID. void
setTargetId(String targetId)
Sets the target ID. String
getChannelId()
Get Channel ID void
setChannelId(String channelId)
Sets the channel ID with a maximum length of 20 characters. int
getMessageId()
Retrieves the unique value (database index unique value) of the locally stored message. void
setMessageId(int messageId)
Sets the unique value for the locally stored message (database index unique value). Message.MessageDirection
getMessageDirection()
Retrieves the message direction. void
setMessageDirection(Message.MessageDirection messageDirection)
Sets the message direction. String
getSenderUserId()
Retrieves the user ID of the message sender. void
setSenderUserId(String senderUserId)
Sets the user ID of the message sender. Message.ReceivedStatus
getReceivedStatus()
Retrieves the receipt status of the message. void
setReceivedStatus(Message.ReceivedStatus receivedStatus)
Sets the received status of the message. Message.SentStatus
getSentStatus()
Retrieves the sending status of the message. void
setSentStatus(Message.SentStatus sentStatus)
Sets the sending status of the message. long
getReceivedTime()
Gets the message received time (Unix timestamp in milliseconds). void
setReceivedTime(long receivedTime)
Sets the message received time (Unix timestamp in milliseconds). long
getSentTime()
Get the message sending time (Unix timestamp, in milliseconds). void
setSentTime(long sentTime)
Sets the message sending time (Unix timestamp in milliseconds). long
getReadTime()
void
setReadTime(long readTime)
String
getObjectName()
Gets the name of the message object. void
setObjectName(String objectName)
Sets the name of the message object. MessageContent
getContent()
Retrieves the message content. void
setContent(MessageContent content)
Sets the message content. String
getExtra()
Retrieves the additional information of the message. void
setExtra(String extra)
Sets the extra information of the message. ReadReceiptInfo
getReadReceiptInfo()
Get the read receipt status void
setReadReceiptInfo(ReadReceiptInfo readReceiptInfo)
Sets the read receipt status ReadReceiptInfoV4
getReadReceiptInfoV4()
Retrieves the Read Receipt V4 information. void
setReadReceiptInfoV4(ReadReceiptInfoV4 readReceiptInfo)
Sets the read receipt V4 information MessageConfig
getMessageConfig()
Get Message Configuration void
setMessageConfig(MessageConfig messageConfig)
Set message configuration MessagePushConfig
getMessagePushConfig()
Get Push Notification Configuration void
setMessagePushConfig(MessagePushConfig messagePushConfig)
Set push notification configuration boolean
isOffline()
Indicates whether the message is an offline message. void
setOffline(boolean offLine)
Sets whether the message is an offline message. Map<String, String>
getExpansion()
List of message extension information List<String>
getDirectedUserIds()
Get the list of targeted users Returns empty for one-to-one chat conversation type void
setDirectedUserIds(List<String> directedUserIds)
Set the list of targeted users boolean
isEmptyContent()
static Message
obtain(String targetId, ConversationType type, MessageContent content)
Constructor. static Message
obtain(ConversationIdentifier conversationIdentifier, MessageContent content)
Constructor. static Message
obtain(String targetId, ConversationType type, String channelId, MessageContent content)
Constructor. void
writeToParcel(Parcel dest, int flags)
int
describeContents()
String
getUId()
Get the unique ID of the server message (globally unique under the same AppKey). void
setUId(String UId)
Sets the unique ID for the server message (globally unique within the same AppKey). GroupReadReceiptInfoV2
getGroupReadReceiptInfoV2()
Get Read Receipt V2 Information void
setGroupReadReceiptInfoV2(GroupReadReceiptInfoV2 v2)
Sets the read receipt V2 information. boolean
isCanIncludeExpansion()
Indicates whether the message can include extended information. void
setExpansion(HashMap<String, String> expansion)
Set the message extension information list Extension information is only supported for one-to-one chat and group chat. boolean
isMayHasMoreMessagesBefore()
boolean
isHasChanged()
Indicates whether the message has been modified. boolean
isDisableUpdateLastMessage()
int
hashCode()
boolean
equals(Object o)
String
toString()
void
setCanIncludeExpansion(boolean canIncludeExpansion)
Sets whether to include extended information. void
setHasChanged(boolean hasChanged)
Sets whether the message has been modified. void
setDisableUpdateLastMessage(boolean disableUpdateLastMessage)
-
-
Method Detail
-
getConversationType
ConversationType getConversationType()
Retrieves the conversation type.
- Returns:
The conversation type.
-
setConversationType
void setConversationType(ConversationType conversationType)
Sets the conversation type.
- Parameters:
conversationType
- Specifies the conversation type.
-
getTargetId
String getTargetId()
Retrieves the target ID.
Depending on the conversationType, this could be a user ID, discussion group ID, group ID, or chatroom ID.
- Returns:
The value of the target ID.
-
setTargetId
void setTargetId(String targetId)
Sets the target ID.
Depending on the conversationType, this could be a user ID, discussion group ID, group ID, or chatroom ID.
- Parameters:
targetId
- The value of the target ID.
-
getChannelId
String getChannelId()
Get Channel ID
- Returns:
Channel ID
-
setChannelId
void setChannelId(String channelId)
Sets the channel ID with a maximum length of 20 characters.
- Parameters:
channelId
- The channel ID
-
getMessageId
int getMessageId()
Retrieves the unique value (database index unique value) of the locally stored message.
- Returns:
The unique value (database index unique value) of the locally stored message.
-
setMessageId
void setMessageId(int messageId)
Sets the unique value for the locally stored message (database index unique value).
- Parameters:
messageId
- The unique value for the locally stored message (database index unique value).
-
getMessageDirection
Message.MessageDirection getMessageDirection()
Retrieves the message direction.
- Returns:
The direction of the message.
-
setMessageDirection
void setMessageDirection(Message.MessageDirection messageDirection)
Sets the message direction.
- Parameters:
messageDirection
- Specifies the message direction.
-
getSenderUserId
String getSenderUserId()
Retrieves the user ID of the message sender.
- Returns:
The user ID of the message sender.
-
setSenderUserId
void setSenderUserId(String senderUserId)
Sets the user ID of the message sender.
- Parameters:
senderUserId
- The user ID of the message sender.
-
getReceivedStatus
Message.ReceivedStatus getReceivedStatus()
Retrieves the receipt status of the message.
- Returns:
The receipt status of the message.
-
setReceivedStatus
void setReceivedStatus(Message.ReceivedStatus receivedStatus)
Sets the received status of the message.
- Parameters:
receivedStatus
- Indicates the received status of the message.
-
getSentStatus
Message.SentStatus getSentStatus()
Retrieves the sending status of the message.
- Returns:
The sending status of the message.
-
setSentStatus
void setSentStatus(Message.SentStatus sentStatus)
Sets the sending status of the message.
- Parameters:
sentStatus
- The sending status of the message.
-
getReceivedTime
long getReceivedTime()
Gets the message received time (Unix timestamp in milliseconds).
The received time is the local time of the client when the message arrives at the receiving client.
- Returns:
The message received time (Unix timestamp in milliseconds).
-
setReceivedTime
void setReceivedTime(long receivedTime)
Sets the message received time (Unix timestamp in milliseconds).
The received time is the local time of the client when the message arrives at the receiving client.
- Parameters:
receivedTime
- The message received time (Unix timestamp in milliseconds).
-
getSentTime
long getSentTime()
Get the message sending time (Unix timestamp, in milliseconds).
The sending time is the server time when the message arrives at the server from the sending client.
- Returns:
The message sending time (Unix timestamp, in milliseconds).
-
setSentTime
void setSentTime(long sentTime)
Sets the message sending time (Unix timestamp in milliseconds).
The sending time is the server time when the message arrives at the server from the sending client.
- Parameters:
sentTime
- The message sending time (Unix timestamp in milliseconds).
-
getReadTime
long getReadTime()
-
setReadTime
void setReadTime(long readTime)
-
getObjectName
String getObjectName()
Gets the name of the message object.
The name of the message object corresponds to the value specified in the annotation.
- Returns:
The name of the message object.
-
setObjectName
void setObjectName(String objectName)
Sets the name of the message object.
The message object name corresponds to the value specified in the annotation.
- Parameters:
objectName
- The name of the message object.
-
getContent
MessageContent getContent()
Retrieves the message content.
- Returns:
The message content.
-
setContent
void setContent(MessageContent content)
Sets the message content.
- Parameters:
content
- The content of the message.
-
getExtra
String getExtra()
Retrieves the additional information of the message.
- Returns:
The additional information of the message.
-
setExtra
void setExtra(String extra)
Sets the extra information of the message.
- Parameters:
extra
- The extra information of the message.
-
getReadReceiptInfo
ReadReceiptInfo getReadReceiptInfo()
Get the read receipt status
- Returns:
The read receipt status
-
setReadReceiptInfo
void setReadReceiptInfo(ReadReceiptInfo readReceiptInfo)
Sets the read receipt status
- Parameters:
readReceiptInfo
- The read receipt status
-
getReadReceiptInfoV4
ReadReceiptInfoV4 getReadReceiptInfoV4()
Retrieves the Read Receipt V4 information.
- Returns:
The Read Receipt V4 information
-
setReadReceiptInfoV4
void setReadReceiptInfoV4(ReadReceiptInfoV4 readReceiptInfo)
Sets the read receipt V4 information
- Parameters:
readReceiptInfo
- The read receipt V4 information
-
getMessageConfig
MessageConfig getMessageConfig()
Get Message Configuration
- Returns:
MessageConfig Specifies the message configuration
-
setMessageConfig
void setMessageConfig(MessageConfig messageConfig)
Set message configuration
- Parameters:
messageConfig
- Message configuration
-
getMessagePushConfig
MessagePushConfig getMessagePushConfig()
Get Push Notification Configuration
- Returns:
MessagePushConfig Push notification configuration
-
setMessagePushConfig
void setMessagePushConfig(MessagePushConfig messagePushConfig)
Set push notification configuration
- Parameters:
messagePushConfig
- Push notification configuration
-
isOffline
boolean isOffline()
Indicates whether the message is an offline message.
This field is invalid for messages retrieved from the database.
Only valid in the message received callback method.
YES if the message is an offline message. NO in all other cases.
-
setOffline
void setOffline(boolean offLine)
Sets whether the message is an offline message.
- Parameters:
offLine
- Indicates whether the message is an offline message.
-
getExpansion
Map<String, String> getExpansion()
List of message extension information
- Returns:
List of message extension information
-
getDirectedUserIds
List<String> getDirectedUserIds()
Get the list of targeted users
Returns empty for one-to-one chat conversation type
- Returns:
The list of targeted users
- Since:
5.8.0
-
setDirectedUserIds
void setDirectedUserIds(List<String> directedUserIds)
Set the list of targeted users
- Parameters:
directedUserIds
- List of targeted users- Since:
5.8.0
-
isEmptyContent
boolean isEmptyContent()
-
obtain
static Message obtain(String targetId, ConversationType type, MessageContent content)
Constructor.
- Parameters:
targetId
- Conversation IDtype
- Conversation typecontent
- Message content- Returns:
Message object
-
obtain
static Message obtain(ConversationIdentifier conversationIdentifier, MessageContent content)
Constructor.
- Parameters:
conversationIdentifier
- Conversation identifiercontent
- Message content- Returns:
Message object
-
obtain
static Message obtain(String targetId, ConversationType type, String channelId, MessageContent content)
Constructor.
- Parameters:
targetId
- Conversation IDtype
- Conversation typechannelId
- Conversation channel IDcontent
- Message content- Returns:
Message object
-
writeToParcel
void writeToParcel(Parcel dest, int flags)
-
describeContents
int describeContents()
-
getUId
String getUId()
Get the unique ID of the server message (globally unique under the same AppKey).
- Returns:
uid The unique ID of the server message (globally unique under the same AppKey).
-
setUId
void setUId(String UId)
Sets the unique ID for the server message (globally unique within the same AppKey).
- Parameters:
UId
- The unique ID for the server message (globally unique within the same AppKey)
-
getGroupReadReceiptInfoV2
GroupReadReceiptInfoV2 getGroupReadReceiptInfoV2()
Get Read Receipt V2 Information
- Returns:
Read Receipt V2 Information
-
setGroupReadReceiptInfoV2
void setGroupReadReceiptInfoV2(GroupReadReceiptInfoV2 v2)
Sets the read receipt V2 information.
- Parameters:
v2
- The read receipt V2 information
-
isCanIncludeExpansion
boolean isCanIncludeExpansion()
Indicates whether the message can include extended information.
This property is determined when the message is sent and cannot be modified afterward. Extended information is only supported in one-to-one and group chats; other conversation types cannot set extended information.
- Returns:
Indicates whether the message can include extended information.
-
setExpansion
void setExpansion(HashMap<String, String> expansion)
Set the message extension information list
Extension information is only supported for one-to-one chat and group chat. Other conversation types cannot set extension information.
By default, the message extension dictionary key length cannot exceed 32, and the value length cannot exceed 4096. The maximum number of extensions that can be set at once is 20, and the total number of extensions for a message cannot exceed 300.
- Parameters:
expansion
- The message extension information list
-
isMayHasMoreMessagesBefore
boolean isMayHasMoreMessagesBefore()
-
isHasChanged
boolean isHasChanged()
Indicates whether the message has been modified.
- Returns:
Specifies whether the message has been modified.
-
isDisableUpdateLastMessage
boolean isDisableUpdateLastMessage()
-
hashCode
int hashCode()
-
equals
boolean equals(Object o)
-
toString
String toString()
-
setCanIncludeExpansion
void setCanIncludeExpansion(boolean canIncludeExpansion)
Sets whether to include extended information.
- Parameters:
canIncludeExpansion
- Indicates whether to include extended information.
-
setHasChanged
void setHasChanged(boolean hasChanged)
Sets whether the message has been modified.
- Parameters:
hasChanged
- Indicates whether the message has been modified.
-
setDisableUpdateLastMessage
void setDisableUpdateLastMessage(boolean disableUpdateLastMessage)
-
-
-
-