Unity and Windows API reference
Public 成员函数 | 静态 Public 成员函数 | Public 属性 | 属性 | 所有成员列表
ChatSDK.Message类 参考

Public 成员函数

 Message (IMessageBody body=null)
 

静态 Public 成员函数

static Message CreateReceiveMessage ()
 
static Message CreateSendMessage (string to, IMessageBody body, MessageDirection direction=MessageDirection.SEND, bool hasRead=true)
 
static Message CreateTextSendMessage (string username, string content)
 
static Message CreateFileSendMessage (string username, string localPath, string displayName="", long fileSize=0)
 
static Message CreateImageSendMessage (string username, string localPath, string displayName="", long fileSize=0, bool original=false, double width=0, double height=0)
 
static Message CreateVideoSendMessage (string username, string localPath, string displayName="", string thumbnailLocalPath="", long fileSize=0, int duration=0, double width=0, double height=0)
 
static Message CreateVoiceSendMessage (string username, string localPath, string displayName="", long fileSize=0, int duration=0)
 
static Message CreateLocationSendMessage (string username, double latitude, double longitude, string address="", string buildingName="")
 
static Message CreateCmdSendMessage (string username, string action, bool deliverOnlineOnly=false)
 
static Message CreateCustomSendMessage (string username, string customEvent, Dictionary< string, string > customParams=null)
 
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 属性

string MsgId = ((long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds)).ToString()
 
string ConversationId = ""
 
string From = ""
 
string To = ""
 
MessageType MessageType
 
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
 

属性

int GroupAckCount [get]
 
List< MessageReactionReactionList [get]
 
ChatThread ChatThread [get]
 

详细描述

消息类,用于定义一条要发送或接收的消息。

成员函数说明

◆ CreateReceiveMessage()

static Message ChatSDK.Message.CreateReceiveMessage ( )
static

创建一条接收的消息。

◆ CreateSendMessage()

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

创建一条发送的消息。

参数
to消息接收方 ID。
body消息体。
direction消息方向,设置为 SEND
  • SEND: 发送该消息。
  • RECEIVE: 接收该消息。
hasRead是否需要已读回执。

◆ CreateTextSendMessage()

static Message ChatSDK.Message.CreateTextSendMessage ( string  username,
string  content 
)
static

创建一条文本发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
content文本内容。

◆ CreateFileSendMessage()

static Message ChatSDK.Message.CreateFileSendMessage ( string  username,
string  localPath,
string  displayName = "",
long  fileSize = 0 
)
static

创建一条文件发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
localPath文件的本地路径。
displayName文件的显示名称。
fileSize文件大小,单位为字节。

◆ CreateImageSendMessage()

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

创建一条图片发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
localPath图片的本地路径。
displayName图片的显示名称。
fileSize图片大小,单位为字节。
original是否发送原图。
  • true: 发送原图。
  • (默认) false: 发送缩略图。若图片超过 100 KB,SDK 会先压缩图片,然后发送缩略图。 对于 Windows、Unity Mac 或 Unity Windows,SDK 暂不支持压缩功能,只支持原图发送。
width图片宽度,单位为像素。
heigh图片高度,单位为像素。

◆ CreateVideoSendMessage()

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

创建一条视频发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
localPath视频文件的 URI。
displayName视频文件的显示名称。
thumbnailLocalPath缩略图的本地路径。
fileSize视频文件的大小,单位为字节。
duration视频时间长度,单位为秒。
width视频宽度,单位为像素。
heigh视频高度,单位为像素。

◆ CreateVoiceSendMessage()

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

创建一条语音发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
localPath语音文件的本地路径。
displayName语音文件的显示名称。
fileSize语音文件的大小,单位为字节。
duration语音时间长度,单位为秒。

◆ CreateLocationSendMessage()

static Message ChatSDK.Message.CreateLocationSendMessage ( string  username,
double  latitude,
double  longitude,
string  address = "",
string  buildingName = "" 
)
static

创建一条位置发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
latitude纬度。
longitude经度。
address位置详情。
buildingName建筑物名称。

◆ CreateCmdSendMessage()

static Message ChatSDK.Message.CreateCmdSendMessage ( string  username,
string  action,
bool  deliverOnlineOnly = false 
)
static

创建一条命令发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
action命令内容。
  • true:只投在线用户。
  • (默认) false:不管用户是否在线均投递。

◆ CreateCustomSendMessage()

static Message ChatSDK.Message.CreateCustomSendMessage ( string  username,
string  customEvent,
Dictionary< string, string >  customParams = null 
)
static

创建一条自定义发送消息。

参数
username消息接收者的用户 ID 或群组 ID。
customEvent自定义事件。
customParams自定义参数字典。

◆ GetAttributeValueType()

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

获取扩展属性的类型。

参数
value扩展属性实例。

◆ SetAttribute()

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

设置单个扩展属性。

参数
arriMap要新增扩展属性的字典。
key新增扩展属性的关键字。
type扩展属性的类型。
value扩展属性的值。

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

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

获取单个扩展属性的泛型类型 T 的数据。

参数
value扩展属性的值。
found扩展属性的值中是否包含泛型类型 T 的数据。
返回
返回泛型类型 T 的数据。
  • foundtrue 时,返回泛型类型 T 的数据
  • foundfalse 时,返回 null

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

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

从扩展属性字典中获取单个扩展属性的泛型类型 T 的数据。

参数
arriMap扩展属性字典。
key扩展属性在字典中的关键字。
found扩展属性的值中是否包含泛型类型 T 的数据。
返回
泛型类型 T 的数据。
  • foundtrue 时,返回泛型类型 T 的数据
  • foundfalse 时,返回 null

类成员变量说明

◆ MsgId

string ChatSDK.Message.MsgId = ((long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds)).ToString()

消息的 ID。

◆ ConversationId

string ChatSDK.Message.ConversationId = ""

消息所属会话的 ID。

◆ From

string ChatSDK.Message.From = ""

消息发送者的 ID。

◆ To

string ChatSDK.Message.To = ""

消息接收者的用户 ID 或群组 ID。

◆ MessageType

MessageType ChatSDK.Message.MessageType

消息类型。

  • Chat:单聊消息;
  • Group:群聊消息;
  • Room:聊天室消息;

◆ Direction

MessageDirection ChatSDK.Message.Direction

消息方向。

  • SEND:该消息由当前用户发出;
  • RECEIVE:该消息由当前用户接收;

详见 Direct

◆ Status

MessageStatus ChatSDK.Message.Status

消息的状态,包含以下状态:

  • CREATE:消息已创建;
  • PROGRESS:消息正在发送;
  • SUCCESS:消息成功发送;
  • FAIL:消息发送失败。

◆ LocalTime

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

消息的本地创建 Unix 时间戳,单位为毫秒。

◆ ServerTime

long ChatSDK.Message.ServerTime = 0

消息的服务器接收的 Unix 时间戳,单位为毫秒。

◆ HasDeliverAck

bool ChatSDK.Message.HasDeliverAck = false

消息是否已送达对方。

  • true: 已送达;
  • false: 未送达。

◆ HasReadAck

bool ChatSDK.Message.HasReadAck = false

消息是否已读。

  • true: 已读;
  • false: 未读。

◆ IsNeedGroupAck

bool ChatSDK.Message.IsNeedGroupAck = false

设置消息是否需要群组已读回执。

参数
need- true:需要已读回执;
  • false:不需要。

◆ IsRead

bool ChatSDK.Message.IsRead = false

消息是否已读。

注解
如要要设置消息已读,建议在会话中,使用 IConversation#MarkAllMessageAsRead()

◆ MessageOnlineState

bool ChatSDK.Message.MessageOnlineState = false

是否为在线消息。

返回
是否在线。
  • true:是。
  • false:是。

◆ Body

IMessageBody ChatSDK.Message.Body

消息体。

◆ Attributes

Dictionary<string, AttributeValue> ChatSDK.Message.Attributes

消息扩展。

◆ IsThread

bool ChatSDK.Message.IsThread = false

设置及获取是否是 Thread 消息。

属性说明

◆ GroupAckCount

int ChatSDK.Message.GroupAckCount
get

获取群组消息回执数。

返回
群组消息回执数。

◆ ReactionList

List<MessageReaction> ChatSDK.Message.ReactionList
get

获取 Reaction 列表。

返回
Reaction 列表。

◆ ChatThread

ChatThread ChatSDK.Message.ChatThread
get

获取子区概览信息。