Chat SDK for Unity and Windows v1.3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
AgoraChat.Message Class Reference
Inheritance diagram for AgoraChat.Message:

Public Member Functions

void SetRoomMessagePriority (RoomMessagePriority priority)
 
List< MessageReactionReactionList ()
 
 Message (IMessageBody body=null)
 

Static Public Member Functions

static Message CreateReceiveMessage ()
 
static Message CreateSendMessage (string to, IMessageBody body, MessageDirection direction=MessageDirection.SEND, bool hasRead=true)
 
static Message CreateTextSendMessage (string userId, string content)
 
static Message CreateFileSendMessage (string userId, string localPath, string displayName="", long fileSize=0)
 
static Message CreateImageSendMessage (string userId, string localPath, string displayName="", long fileSize=0, bool original=false, double width=0, double height=0)
 
static Message CreateVideoSendMessage (string userId, string localPath, string displayName="", string thumbnailLocalPath="", long fileSize=0, int duration=0, double width=0, double height=0)
 
static Message CreateVoiceSendMessage (string userId, string localPath, string displayName="", long fileSize=0, int duration=0)
 
static Message CreateLocationSendMessage (string userId, double latitude, double longitude, string address="", string buildingName="")
 
static Message CreateCmdSendMessage (string userId, string action, bool deliverOnlineOnly=false)
 
static Message CreateCustomSendMessage (string userId, string customEvent, Dictionary< string, string > customParams=null)
 
static Message CreateCombineSendMessage (string userId, string title, string summary, string compatibleText, List< string > messageList)
 
static AttributeValueType GetAttributeValueType (AttributeValue value)
 
static void SetAttribute (Dictionary< string, AttributeValue > arriMap, string key, in object value, AttributeValueType type)
 
static T GetAttributeValue< T > (AttributeValue value, out bool found)
 
static T GetAttributeValue< T > (Dictionary< string, AttributeValue > arriMap, string key, out bool found)
 

Public Attributes

string MsgId = ((long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds) + Tools.GetRandom()).ToString()
 
string ConversationId = ""
 
string From = ""
 
string To = ""
 
MessageType MessageType
 
bool DeliverOnlineOnly = false
 
MessageDirection Direction
 
MessageStatus Status
 
long LocalTime = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds)
 
long ServerTime = 0
 
bool HasDeliverAck = false
 
bool HasReadAck = false
 
bool IsNeedGroupAck = false
 
bool IsRead = false
 
bool MessageOnlineState = false
 
IMessageBody Body
 
Dictionary< string, AttributeValue > Attributes
 
bool IsThread = false
 
bool Broadcast = false
 
bool IsContentReplaced = false
 

Properties

int GroupAckCount [get]
 
PinnedInfo PinnedInfo [get]
 
List< string > ReceiverList [get, set]
 
ChatThread ChatThread [get]
 

Member Function Documentation

◆ SetRoomMessagePriority()

void AgoraChat.Message.SetRoomMessagePriority ( RoomMessagePriority  priority)

Sets the priority of the chat room message.

◆ ReactionList()

List< MessageReaction > AgoraChat.Message.ReactionList ( )

Gets the list of Reactions.

Returns
The list of Reactions.

◆ CreateReceiveMessage()

static Message AgoraChat.Message.CreateReceiveMessage ( )
static

Creates a received message instance.

◆ CreateSendMessage()

static Message AgoraChat.Message.CreateSendMessage ( string  to,
IMessageBody  body,
MessageDirection  direction = MessageDirection.SEND,
bool  hasRead = true 
)
static

Creates a message instance for sending.

Parameters
toThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
bodyThe message body.
directionThe message direction, that is, whether the message is received or sent. This parameter is set to SEND.
  • SEND: This message is sent from the local client.
  • RECEIVE: The message is received by the local client.
hasReadWhether a read receipt is required.
  • true: Yes.
  • false: No.

◆ CreateTextSendMessage()

static Message AgoraChat.Message.CreateTextSendMessage ( string  userId,
string  content 
)
static

Creates a text message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
contentThe text content.

◆ CreateFileSendMessage()

static Message AgoraChat.Message.CreateFileSendMessage ( string  userId,
string  localPath,
string  displayName = "",
long  fileSize = 0 
)
static

Creates a file message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
localPathThe local path of the file.
displayNameThe display name of the file.
fileSizeThe file size in bytes.

◆ CreateImageSendMessage()

static Message AgoraChat.Message.CreateImageSendMessage ( string  userId,
string  localPath,
string  displayName = "",
long  fileSize = 0,
bool  original = false,
double  width = 0,
double  height = 0 
)
static

Creates an image message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
localPathThe local path of the image.
displayNameThe display name of the image.
fileSizeThe image size in bytes.
originalWhether to send the original image.
  • true: Yes.
  • (Default) false: No. The thumbnail is sent. For an image greater than 100 KB, the SDK will compress it before sending its thumbnail.
widthThe image width in pixels.
heighThe image height in pixels.

◆ CreateVideoSendMessage()

static Message AgoraChat.Message.CreateVideoSendMessage ( string  userId,
string  localPath,
string  displayName = "",
string  thumbnailLocalPath = "",
long  fileSize = 0,
int  duration = 0,
double  width = 0,
double  height = 0 
)
static

Creates a video message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
localPathThe URI of the video file.
displayNameThe display name of the video file.
thumbnailLocalPathThe local path of the thumbnail of the video file.
fileSizeThe size of the video file, in bytes.
durationThe video duration in seconds.
widthThe video width in pixels.
heighThe video height in pixels.

◆ CreateVoiceSendMessage()

static Message AgoraChat.Message.CreateVoiceSendMessage ( string  userId,
string  localPath,
string  displayName = "",
long  fileSize = 0,
int  duration = 0 
)
static

Creates a voice message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
localPathThe local path of the voice file.
displayNameThe display name of f the voice file.
fileSizeThe size of the voice file, in bytes.
durationThe voice duration in seconds.

◆ CreateLocationSendMessage()

static Message AgoraChat.Message.CreateLocationSendMessage ( string  userId,
double  latitude,
double  longitude,
string  address = "",
string  buildingName = "" 
)
static

Creates a location message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
latitudeThe latitude.
longitudeThe longitude.
addressThe location details.
buildingNameThe building name.

◆ CreateCmdSendMessage()

static Message AgoraChat.Message.CreateCmdSendMessage ( string  userId,
string  action,
bool  deliverOnlineOnly = false 
)
static

Creates a command message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
actionThe command action.
deliverOnlineOnlyWhether this command message is delivered only to the online users.
  • true: Yes.
  • (Default) false: No. The command message is delivered to users, regardless of their online or offline status.

◆ CreateCustomSendMessage()

static Message AgoraChat.Message.CreateCustomSendMessage ( string  userId,
string  customEvent,
Dictionary< string, string >  customParams = null 
)
static

Creates a custom message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
customEventThe custom event.
customParamsThe dictionary of custom parameters.

◆ CreateCombineSendMessage()

static Message AgoraChat.Message.CreateCombineSendMessage ( string  userId,
string  title,
string  summary,
string  compatibleText,
List< string >  messageList 
)
static

Creates a combined message for sending.

Parameters
userIdThe message recipient:
  • One-to-one chat: The user ID of the peer user.
  • Group chat: Group ID.
  • Chat room: Chat room ID.
  • Thread: Thread ID.
titleThe title of the combined message. It can be null or an empty string ("").
summaryThe summary of the combined message. It can be null or an empty string ("").
compatibleTextThe compatible text of the combined message. It can be null or an empty string ("").
messageListThe ID list of messages included in the combined message. The list cannot be null or empty. It can contain a maximum of 300 message IDs.

◆ GetAttributeValueType()

static AttributeValueType AgoraChat.Message.GetAttributeValueType ( AttributeValue  value)
static

Gets the type of the message extension attribute.

Parameters
valueThe extension attribute instance.

◆ SetAttribute()

static void AgoraChat.Message.SetAttribute ( Dictionary< string, AttributeValue >  arriMap,
string  key,
in object  value,
AttributeValueType  type 
)
static

Sets an extension attribute.

Parameters
arriMapThe dictionary to which the new extension attribute will be added.
keyThe keyword of the extension attribute.
typeThe type of the extension attribute.
valueThe value of the extension attribute.

◆ GetAttributeValue< T >() [1/2]

static T AgoraChat.Message.GetAttributeValue< T > ( AttributeValue  value,
out bool  found 
)
static

Gets the data of the generic <T> type of an extension attribute.

Parameters
valueThe value of the extension attribute.
foundWhether the data of the generic <T> type is included in the value of the extension attribute.
Returns
The data of the generic <T> type.
  • If found is true, the data of the generic <T> type is returned.
  • If found is false, null is returned.

◆ GetAttributeValue< T >() [2/2]

static T AgoraChat.Message.GetAttributeValue< T > ( Dictionary< string, AttributeValue >  arriMap,
string  key,
out bool  found 
)
static

Gets the data of the generic <T> type of an extension attribute from the extension attribute dictionary.

Parameters
arriMapThe dictionary which contains attributes.
keyThe keyword in the dictionary for the extension attribute.
foundWhether the data of the generic <T> type is included in the value of the extension attribute.
Returns
The data of the generic <T> type.
  • If found is true, the data of the generic <T> type is returned.
  • If found is false, null is returned.

Member Data Documentation

◆ MsgId

string AgoraChat.Message.MsgId = ((long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds) + Tools.GetRandom()).ToString()

The message ID.

◆ ConversationId

string AgoraChat.Message.ConversationId = ""

The ID of the conversation to which the message belongs.

◆ From

string AgoraChat.Message.From = ""

The user ID of the message sender.

◆ To

string AgoraChat.Message.To = ""

The message recipient.

  • For a one-to-one chat, it is the user ID of the peer user.
  • For a group chat, it is the group ID.
  • For a chat room, it is the chat room ID.

◆ MessageType

MessageType AgoraChat.Message.MessageType

The chat type.

◆ DeliverOnlineOnly

bool AgoraChat.Message.DeliverOnlineOnly = false

Whether the message is delivered only when the recipient(s) is/are online:

  • true:The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
  • (Default) false:The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.

◆ Direction

MessageDirection AgoraChat.Message.Direction

The message direction, that is, whether the message is received or sent.

  • SEND: This message is sent from the local client.
  • RECEIVE: The message is received by the local client.

See Direct.

◆ Status

MessageStatus AgoraChat.Message.Status

The message status, which can be one of the following:

  • CREATE:The message is created.
  • PROGRESS:The message is being delivered.
  • SUCCESS:The message is successfully delivered.
  • FAIL:The message fails to be delivered.

◆ LocalTime

long AgoraChat.Message.LocalTime = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds)

The local Unix timestamp for creating the message. The unit is millisecond.

◆ ServerTime

long AgoraChat.Message.ServerTime = 0

The Unix timestamp when the message is received by the server. The unit is millisecond.

◆ HasDeliverAck

bool AgoraChat.Message.HasDeliverAck = false

Whether the message is delivered.

  • true: Yes.
  • false: No.

◆ HasReadAck

bool AgoraChat.Message.HasReadAck = false

Whether the message is read.

-true: Yes. -false: No.

◆ IsNeedGroupAck

bool AgoraChat.Message.IsNeedGroupAck = false

Whether read receipts are required for group messages.

  • true: Yes.
  • false: No.

◆ IsRead

bool AgoraChat.Message.IsRead = false

Whether the message is read or not.

Note
To set the message as read, you are advised to use Conversation#MarkAllMessagesAsRead() in a conversation.

◆ MessageOnlineState

bool AgoraChat.Message.MessageOnlineState = false

Whether the message is an online message.

Returns
Whether the message is an online message.
  • true: Yes.
  • false: No.

◆ Body

IMessageBody AgoraChat.Message.Body

The message body.

◆ Attributes

Dictionary<string, AttributeValue> AgoraChat.Message.Attributes

The message extension.

◆ IsThread

bool AgoraChat.Message.IsThread = false

Whether the message is in a message thread:

  • true: Yes.
  • false: No.

This property is read only.

◆ Broadcast

bool AgoraChat.Message.Broadcast = false

Whether it is a global broadcast message for all chat rooms in an app:

  • true: Yes.
  • false: No.

This property is read only.

◆ IsContentReplaced

bool AgoraChat.Message.IsContentReplaced = false

Whether the content of message is replaced:

  • true: Yes.
  • false: No.

This property is read only.

Property Documentation

◆ GroupAckCount

int AgoraChat.Message.GroupAckCount
get

Gets the number of read receipts for a group message.

Returns
The number of read receipts for a group message.

◆ PinnedInfo

PinnedInfo AgoraChat.Message.PinnedInfo
get

Gets the message pinning information.

Returns
The message pinning information.

◆ ReceiverList

List<string> AgoraChat.Message.ReceiverList
getset

The recipient list of a targeted message.

This property is used only for messages in groups and chat rooms.

◆ ChatThread

ChatThread AgoraChat.Message.ChatThread
get

Gets the overview of the message thread.

The overview of the message thread exists only after you create a message thread.