Chat SDK for Unity and Windows v1.2.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
 

Properties

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

Member Function Documentation

◆ SetRoomMessagePriority()

void AgoraChat.Message.SetRoomMessagePriority ( RoomMessagePriority  priority)

Sets the priority of chat room messages.

◆ ReactionList()

List< MessageReaction > AgoraChat.Message.ReactionList ( )

Get 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 user ID of the message recipient.
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 user ID of the message recipient, group ID, thread ID, or chatroom 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 user ID of the message recipient, group ID, thread ID, or chatroom 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 user ID of the message recipient, group ID, thread ID, or chatroom 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 user ID of the message recipient, group ID, thread ID, or chatroom 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 user ID of the message recipient, group ID, thread ID, or chatroom 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 user ID of the message recipient, group ID, thread ID, or chatroom 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 user ID of the message recipient, group ID, thread ID, or chatroom 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 user ID of the message recipient, group ID, thread ID, or chatroom 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 an image message for sending.

Parameters
userIdThe user ID of the message recipient, group ID, thread ID, or chatroom ID.
titleThe title of combined message.
summaryThe summary of combined message.
messageListThe message Id list included in combined message.

◆ 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 user ID of the message recipient or the group ID.

◆ MessageType

MessageType AgoraChat.Message.MessageType

The message type.

  • Chat: The one-to-one chat message.
  • Group: The group chat message.
  • Room: The chat room message.

◆ 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

Sets whether read receipts are required for group messages.

Parameters
need- true: Yes.
  • false: No.

◆ IsRead

bool AgoraChat.Message.IsRead = false

Check the message is read or not.

Note
If you want to set message read, we recommend you 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 thread:

  • true: Yes.
  • false: No.

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.

◆ ReceiverList

List<string> AgoraChat.Message.ReceiverList
getset

The list of IDs of group or chat room members that receive a message.

◆ ChatThread

ChatThread AgoraChat.Message.ChatThread
get

Gets the overview of the message thread.

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