public abstract class BaseMessage
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
BaseMessage.GetMessageHandler
GetMessage handler.
|
static interface |
BaseMessage.GetThreadedMessagesHandler
GetThreadedMessages handler.
|
static class |
BaseMessage.SendingStatus
Represents message sending status.
|
Constructor and Description |
---|
BaseMessage(java.lang.String channelUrl,
long msgId,
long createdAt) |
Modifier and Type | Method and Description |
---|---|
boolean |
applyParentMessage(BaseMessage parentMessage)
When parent message is updated, you can update the child message's parent message through this method
If you use MessageCollection, messages in the collection are automatically updated, so don't need to call it
|
boolean |
applyReactionEvent(ReactionEvent reactionEvent)
Applies
ReactionEvent to message. |
boolean |
applyThreadInfoUpdateEvent(ThreadInfoUpdateEvent threadInfoUpdateEvent)
Applies
ThreadInfoUpdateEvent to a message. |
static boolean |
belongsTo(BaseMessage message,
java.lang.String userId)
Checks whether the sender's userId of the
BaseMessage equals the given userId. |
static boolean |
belongsTo(BaseMessage message,
User user)
Checks whether the sender's userId of the
BaseMessage equals the given user's id. |
static BaseMessage |
buildFromSerializedData(byte[] data)
Builds
UserMessage , FileMessage or AdminMessage instance
from serialized data generated by serialize() . |
static BaseMessage |
buildFromSerializedData(byte[] data,
BaseMessage.SendingStatus desiredState)
Builds
UserMessage , FileMessage or AdminMessage
instance from serialized data generated by serialize() . |
static BaseMessage |
clone(BaseMessage msg)
Clones and returns a new instance of given BaseMessage
|
boolean |
equals(java.lang.Object o) |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getAllMetaArray()
Deprecated.
As of 3.0.99, replaced by
getAllMetaArrays() . |
java.util.List<MessageMetaArray> |
getAllMetaArrays()
Returns all
MessageMetaArray s. |
AppleCriticalAlertOptions |
getAppleCriticalAlertOptions()
gets apple critical alert options of this instance.
|
java.lang.String |
getChannelUrl()
Returns the channel URL of this message belongs to.
|
long |
getCreatedAt()
Returns message creation time.
|
java.lang.String |
getCustomType()
Returns the custom type of message.
|
java.lang.String |
getData()
Returns message custom data.
|
int |
getErrorCode()
Returns error code.
|
java.lang.String |
getMentionedMessageTemplate()
Returns the mentioned message template.
|
java.util.List<User> |
getMentionedUsers()
Returns mentioned users.
|
BaseMessageParams.MentionType |
getMentionType()
Returns mention type.
|
java.lang.String |
getMessage()
Returns message text.
|
static void |
getMessage(MessageRetrievalParams params,
BaseMessage.GetMessageHandler handler)
Retrieves a
BaseMessage object with a specified message ID. |
long |
getMessageId()
Returns message ID.
|
int |
getMessageSurvivalSeconds()
Returns the message's survival seconds.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getMetaArray(java.util.Collection<java.lang.String> metaArrayKeys)
Deprecated.
As of 3.0.99, replaced by
getMetaArrays(Collection) . |
java.util.List<MessageMetaArray> |
getMetaArrays(java.util.Collection<java.lang.String> metaArrayKeys)
Returns
MessageMetaArray list which is filtered by given metaArrayKeys. |
OGMetaData |
getOgMetaData()
Retrieve
OGMetaData of the message. |
BaseMessage |
getParentMessage()
Returns the parent message of this message.
|
long |
getParentMessageId()
Returns the parent message's ID if this is a child message.
|
java.lang.String |
getParentMessageText()
Deprecated.
As of 3.0.173, replaced by
getParentMessage() . |
java.util.List<Reaction> |
getReactions()
Returns reactions.
|
abstract java.lang.String |
getRequestId()
Returns a message request ID.
|
Sender |
getSender()
Returns sender of message.
|
BaseMessage.SendingStatus |
getSendingStatus()
Returns message sending status.
|
void |
getThreadedMessagesByTimestamp(long ts,
ThreadMessageListParams params,
BaseMessage.GetThreadedMessagesHandler handler)
Retrieves the threaded replies of the current message depending on the timestamp.
|
ThreadInfo |
getThreadInfo()
The thread info that belongs to this message object.
|
long |
getUpdatedAt()
Returns message updated time.
|
int |
hashCode() |
boolean |
isGroupChannel()
Checks if this message is from
GroupChannel . |
boolean |
isOpenChannel()
Checks if this message is from
OpenChannel . |
boolean |
isOperatorMessage()
Returns boolean value that can be used to test if the message was sent from an operator.
|
boolean |
isReplyToChannel()
Determines whether the current message is a replied message and also a message was replied to the channel.
|
boolean |
isResendable()
Returns whether resend is possible.
|
boolean |
isSilent()
Checks whether the message is silent or not.
|
byte[] |
serialize()
Serializes the
UserMessage , FileMessage or AdminMessage instance. |
void |
setAppleCriticalAlertOptions(AppleCriticalAlertOptions appleCriticalAlertOptions)
sets apple critical alert options for this instance.
|
java.lang.String |
toString() |
public BaseMessage(java.lang.String channelUrl, long msgId, long createdAt)
public static void getMessage(MessageRetrievalParams params, BaseMessage.GetMessageHandler handler)
BaseMessage
object with a specified message ID.params
- MessageRetrievalParams
.handler
- Callback handler.public abstract java.lang.String getRequestId()
public java.lang.String getMessage()
public Sender getSender()
SendBird.Options.useMemberAsMessageSender(boolean)
is set true
,
the sender information such as nickname and profile url is returned as the same with the channel member's. Otherwise,
the sender information will be returned as the value of the message creation time.Sender
of the message. Can be null.public BaseMessage.SendingStatus getSendingStatus()
BaseMessage.SendingStatus
).public boolean isResendable()
public static boolean belongsTo(BaseMessage message, java.lang.String userId)
BaseMessage
equals the given userId.message
- BaseMessage
to check userId.userId
- UserId to check. Returns false if userId is null or empty.false
if userId is null or empty or message is null.public static boolean belongsTo(BaseMessage message, User user)
BaseMessage
equals the given user's id.message
- BaseMessage
to check user.user
- User to check. Returns false if user is null.false
if user or message is null.public static BaseMessage buildFromSerializedData(byte[] data)
UserMessage
, FileMessage
or AdminMessage
instance
from serialized data generated by serialize()
.data
- Serialized UserMessage
, FileMessage
or AdminMessage
data.UserMessage
, FileMessage
or AdminMessage
instance.public static BaseMessage buildFromSerializedData(byte[] data, BaseMessage.SendingStatus desiredState)
UserMessage
, FileMessage
or AdminMessage
instance from serialized data generated by serialize()
.
Unlike buildFromSerializedData(byte[])
, this method takes an extra argument
'desiredState'. This argument will override the returned BaseMessage's SendingStatus.
Under normal development scenarios, most application developers won't need to use this
method. Changing a message's sending state may corrupt Sendbird SDK's internal states and
may lead to undesired results.
The rebuilt BaseMessage
instance will have an error code of
SendBirdError#ERR_PENDING
if the instance's BaseMessage.SendingStatus
changed from
BaseMessage.SendingStatus.PENDING
to BaseMessage.SendingStatus.FAILED
.data
- Serialized UserMessage
, FileMessage
or
AdminMessage
data.UserMessage
, FileMessage
or AdminMessage
instance.public byte[] serialize()
UserMessage
, FileMessage
or AdminMessage
instance.
This byte array can be stored in the database in your application.
The instance can be restored by buildFromSerializedData(byte[])
.UserMessage
, FileMessage
or AdminMessage
data.public long getMessageId()
public long getParentMessageId()
public long getCreatedAt()
public long getUpdatedAt()
public BaseMessageParams.MentionType getMentionType()
BaseMessageParams.MentionType
.public java.lang.String getMentionedMessageTemplate()
public java.util.List<User> getMentionedUsers()
public java.lang.String getChannelUrl()
public boolean isOpenChannel()
OpenChannel
.OpenChannel
.public boolean isGroupChannel()
GroupChannel
.GroupChannel
.public java.lang.String getData()
public java.lang.String getCustomType()
public java.util.List<Reaction> getReactions()
@Deprecated public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getAllMetaArray()
getAllMetaArrays()
.public java.util.List<MessageMetaArray> getAllMetaArrays()
MessageMetaArray
s.MessageMetaArray
@Deprecated public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMetaArray(java.util.Collection<java.lang.String> metaArrayKeys)
getMetaArrays(Collection)
.metaArrayKeys
- Meta array keys.public java.util.List<MessageMetaArray> getMetaArrays(java.util.Collection<java.lang.String> metaArrayKeys)
MessageMetaArray
list which is filtered by given metaArrayKeys.metaArrayKeys
- Meta array Keys.MessageMetaArray
.public int getErrorCode()
public int getMessageSurvivalSeconds()
public boolean applyReactionEvent(ReactionEvent reactionEvent)
ReactionEvent
to message.reactionEvent
- ReactionEvent reaction event from onReactionUpdated().public boolean applyThreadInfoUpdateEvent(ThreadInfoUpdateEvent threadInfoUpdateEvent)
ThreadInfoUpdateEvent
to a message.threadInfoUpdateEvent
- ThreadInfoUpdateEvent
from SendBird.ChannelHandler.onThreadInfoUpdated(BaseChannel, ThreadInfoUpdateEvent)
.true
if the event has been applied successfully.public void getThreadedMessagesByTimestamp(long ts, ThreadMessageListParams params, BaseMessage.GetThreadedMessagesHandler handler)
handler
as list
.ts
- Specifies the timestamp to be the reference point of the retrieval, in Unix milliseconds format.params
- Params for getting thread message list. See ThreadMessageListParams
handler
- Callback handler.public ThreadInfo getThreadInfo()
@Deprecated public java.lang.String getParentMessageText()
getParentMessage()
.null
if it doesn't have a parent message.public boolean isSilent()
true
if the message is silent.public OGMetaData getOgMetaData()
OGMetaData
of the message.
Might be null if
1. Application does not support OG-TAG. (all new applications support OG-TAG by default)
2. The message does not contain a valid url.
3. The server did not fetch the OG-Tag yet. (would be updated through
SendBird.ChannelHandler.onMessageUpdated(BaseChannel, BaseMessage)
callback.OGMetaData
instance, if available.OGMetaData
public boolean isOperatorMessage()
This value is true if the sender of this message was an operator at the moment this message was sent.
Note that Sender.getRole()
returns the role of the sender at the current moment (when
the server response was sent). So if the sender's operator status changed after sending a
message, the value returned by this method and the result of
Sender#getRole() == Member.Role.OPERATOR
might differ.Sender.getRole()
public AppleCriticalAlertOptions getAppleCriticalAlertOptions()
AppleCriticalAlertOptions
instance of this instance or null.public void setAppleCriticalAlertOptions(AppleCriticalAlertOptions appleCriticalAlertOptions)
appleCriticalAlertOptions
- an instance of AppleCriticalAlertOptions
public boolean isReplyToChannel()
public BaseMessage getParentMessage()
NonNull
if this message is a threaded message.
It does not contain all properties of the parent message.getMessage()
.getSender()
. (null if the parent message is an AdminMessage
). getCreatedAt()
. FileMessage
.FileMessage.getName()
.FileMessage.getType()
.FileMessage.getUrl()
.NonNull
if this message is a threaded message.public boolean applyParentMessage(BaseMessage parentMessage)
parentMessage
- updated parent message. It should be the same with the current parentMessagepublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static BaseMessage clone(BaseMessage msg)
msg
- BaseMessage
object to clone.BaseMessage
. Copyright © 2021, Sendbird or its affiliates. All rights reserved.
Report a bug or request a feature
For further developer documentation, see Chat SDK Documentation. That documentation contains more detailed descriptions, conceptual overviews, definitions of terms, and code examples.