Chat SDK for Unity and Windows v1.2.0
Public 成员函数 | 所有成员列表
AgoraChat.ChatManager类 参考
类 AgoraChat.ChatManager 继承关系图:

Public 成员函数

bool DeleteConversation (string conversationId, bool deleteMessages=true)
 
void DownloadAttachment (string messageId, CallBack callback=null)
 
void DownloadThumbnail (string messageId, CallBack callback=null)
 
void FetchHistoryMessagesFromServer (string conversationId, ConversationType type=ConversationType.Chat, string startMessageId=null, int count=20, MessageSearchDirection direction=MessageSearchDirection.UP, ValueCallBack< CursorResult< Message > > callback=null)
 
void FetchHistoryMessagesFromServerBy (string conversationId, ConversationType type=ConversationType.Chat, string cursor=null, int pageSize=10, FetchServerMessagesOption option=null, ValueCallBack< CursorResult< Message > > callback=null)
 
Conversation GetConversation (string conversationId, ConversationType type=ConversationType.Chat, bool createIfNeed=true)
 
Conversation GetThreadConversation (string threadId)
 
void GetConversationsFromServer (ValueCallBack< List< Conversation > > callback=null)
 
void GetConversationsFromServerWithCursor (bool pinOnly, string cursor="", int limit=20, ValueCallBack< CursorResult< Conversation > > callback=null)
 
int GetUnreadMessageCount ()
 
void ImportMessages (List< Message > messages, CallBack callback=null)
 
List< ConversationLoadAllConversations ()
 
Message LoadMessage (string messageId)
 
bool MarkAllConversationsAsRead ()
 
void RecallMessage (string messageId, CallBack callback=null)
 
Message ResendMessage (string messageId, CallBack callback=null)
 
List< MessageSearchMsgFromDB (string keywords, long timestamp=0, int maxCount=20, string from=null, MessageSearchDirection direction=MessageSearchDirection.UP)
 
void SendConversationReadAck (string conversationId, CallBack callback=null)
 
void SendMessage (ref Message message, CallBack callback=null)
 
void SendMessageReadAck (string messageId, CallBack callback=null)
 
void SendReadAckForGroupMessage (string messageId, string ackContent, CallBack callback=null)
 
bool UpdateMessage (Message message)
 
void ModifyMessage (string messageId, MessageBody.TextBody body, ValueCallBack< Message > callback=null)
 
void RemoveMessagesBeforeTimestamp (long timeStamp, CallBack callback=null)
 
void DeleteConversationFromServer (string conversationId, ConversationType conversationType, bool isDeleteServerMessages, CallBack callback=null)
 
void FetchSupportLanguages (ValueCallBack< List< SupportLanguage > > callback=null)
 
void TranslateMessage (Message message, List< string > targetLanguages, ValueCallBack< Message > callback=null)
 
void FetchGroupReadAcks (string messageId, string groupId, int pageSize=20, string startAckId=null, ValueCallBack< CursorResult< GroupReadAck > > callback=null)
 
void ReportMessage (string messageId, string tag, string reason, CallBack callback=null)
 
void AddReaction (string messageId, string reaction, CallBack callback=null)
 
void RemoveReaction (string messageId, string reaction, CallBack callback=null)
 
void GetReactionList (List< string > messageIdList, MessageType chatType, string groupId, ValueCallBack< Dictionary< string, List< MessageReaction > > > callback=null)
 
void GetReactionDetail (string messageId, string reaction, string cursor=null, int pageSize=20, ValueCallBack< CursorResult< MessageReaction > > callback=null)
 
void GetConversationsFromServerWithPage (int pageNum, int pageSize, ValueCallBack< List< Conversation > > callback=null)
 
void RemoveMessagesFromServer (string conversationId, ConversationType conversationType, List< string > messageIdList, CallBack callback=null)
 
void RemoveMessagesFromServer (string conversationId, ConversationType conversationType, long timeStamp, CallBack callback=null)
 
void PinConversation (string conversationId, bool isPinned, CallBack callback=null)
 
void FetchCombineMessageDetail (Message msg, ValueCallBack< List< Message > > callback=null)
 
void AddChatManagerDelegate (IChatManagerDelegate chatManagerDelegate)
 
void RemoveChatManagerDelegate (IChatManagerDelegate chatManagerDelegate)
 

成员函数说明

◆ DeleteConversation()

bool AgoraChat.ChatManager.DeleteConversation ( string  conversationId,
bool  deleteMessages = true 
)

删除本地数据库中的指定会话及其历史消息。

若将 deleteMessages 设置为 true,删除会话的同时也会删除该会话的本地历史消息。

参数
conversationId会话 ID。
deleteMessages是否同时删除本地历史消息:
  • true :是;
  • false :否。
isThread删除会话是否是子区会话。
  • true 是子区会话;
  • false 不是子区会话。
返回
会话是否成功删除:
  • true :是;
  • false :否。

◆ DownloadAttachment()

void AgoraChat.ChatManager.DownloadAttachment ( string  messageId,
CallBack  callback = null 
)

下载消息的附件。

若附件自动下载失败,也可以调用此方法下载。

参数
messageId要下载附件的消息 ID。
callback下载结果回调,详见 CallBack

◆ DownloadThumbnail()

void AgoraChat.ChatManager.DownloadThumbnail ( string  messageId,
CallBack  callback = null 
)

下载消息的缩略图。

若消息缩略图自动下载失败,也可以调用该方法下载。

参数
messageId要下载缩略图的消息 ID,一般图片消息和视频消息有缩略图。
callback下载结果回调,详见 CallBack

◆ FetchHistoryMessagesFromServer()

void AgoraChat.ChatManager.FetchHistoryMessagesFromServer ( string  conversationId,
ConversationType  type = ConversationType.Chat,
string  startMessageId = null,
int  count = 20,
MessageSearchDirection  direction = MessageSearchDirection.UP,
ValueCallBack< CursorResult< Message > >  callback = null 
)

从服务器获取历史消息。

分页获取。

异步方法。

参数
conversationId会话 ID。
type会话类型,详见 ConversationType
startMessageId漫游消息的开始消息 ID。如果为空,SDK 按服务器接收消息时间的倒序获取。
count每页期望返回的的消息条数。
direction消息获取的方向。
callback结果回调,返回消息列表。

◆ FetchHistoryMessagesFromServerBy()

void AgoraChat.ChatManager.FetchHistoryMessagesFromServerBy ( string  conversationId,
ConversationType  type = ConversationType.Chat,
string  cursor = null,
int  pageSize = 10,
FetchServerMessagesOption  option = null,
ValueCallBack< CursorResult< Message > >  callback = null 
)

根据根据消息拉取参数配置类 FetchServerMessagesOption 从服务器分页获取历史消息。

分页获取历史消息。

异步方法。

参数
conversationId会话 ID。
type会话类型,详见 ConversationType
cursor查询的起始游标位置。
pageSize每页期望获取的消息条数。取值范围为 [1,50]。
option查询历史消息的参数配置接口,详见 FetchServerMessagesOption
callback结果回调,返回消息列表。

◆ GetConversation()

Conversation AgoraChat.ChatManager.GetConversation ( string  conversationId,
ConversationType  type = ConversationType.Chat,
bool  createIfNeed = true 
)

获取本地指定会话对象。

参数
conversationId会话 ID。
type会话类型,详见 ConversationType
createIfNeed本地数据库中未找到相应会话时是否自动创建。
  • true:是;
  • false:否。
isThread获取会话是否是子区会话。
  • true 是子区会话;
  • false 不是子区会话。
返回
根据指定会话 ID 找到的会话对象。未找到会话会返回空值。

◆ GetThreadConversation()

Conversation AgoraChat.ChatManager.GetThreadConversation ( string  threadId)

获取本地指定子区会话对象。

参数
threadId子区 ID。
返回
根据指定会话 ID 获取子区会话对象。

◆ GetConversationsFromServer()

void AgoraChat.ChatManager.GetConversationsFromServer ( ValueCallBack< List< Conversation > >  callback = null)

从服务器获取所有会话对象。

未找到任何会话对象返回的列表为空。

参数
callback获取的会话列表,详见 ValueCallBack

◆ GetConversationsFromServerWithCursor()

void AgoraChat.ChatManager.GetConversationsFromServerWithCursor ( bool  pinOnly,
string  cursor = "",
int  limit = 20,
ValueCallBack< CursorResult< Conversation > >  callback = null 
)

根据指定参数从服务器获取相关会话对象。

参数
pinOnly是否只获取置顶会话:
  • true:是。只获取置顶会话。SDK 按照会话置顶时间倒序返回。
  • false:否。
cursor开始获取数据的游标位置。
limit每页返回的会话数。取值范围为 [1,50]。
callback获取的会话列表,详见 ValueCallBack

◆ GetUnreadMessageCount()

int AgoraChat.ChatManager.GetUnreadMessageCount ( )

获取未读消息数。

返回
未读消息数。

◆ ImportMessages()

void AgoraChat.ChatManager.ImportMessages ( List< Message messages,
CallBack  callback = null 
)

将消息导入本地数据库。

你只能将你发送或接受的消息导入本地数据库。

参数
messages要导入数据库的消息。
返回
消息是否成功导入本地数据库。
  • true: 成功;
  • false: 失败。

◆ LoadAllConversations()

List< Conversation > AgoraChat.ChatManager.LoadAllConversations ( )

将本地数据库中的所有会话加载到内存。

一般情况下,该方法在成功登录后调用,以提升会话列表的加载速度。

返回
加载的会话列表。

◆ LoadMessage()

Message AgoraChat.ChatManager.LoadMessage ( string  messageId)

将本地数据库中的指定消息加载到内存。

参数
messageId需加载的消息的 ID。
返回
加载的消息对象。

◆ MarkAllConversationsAsRead()

bool AgoraChat.ChatManager.MarkAllConversationsAsRead ( )

将本地所有会话设置为已读。

返回
所有会话是否成功设置为已读。
  • true:是;
  • false:否。

◆ RecallMessage()

void AgoraChat.ChatManager.RecallMessage ( string  messageId,
CallBack  callback = null 
)

撤回已发送的消息。

异步方法。

参数
messageId要撤回消息的 ID。
callback撤回结果回调,详见 CallBack

◆ ResendMessage()

Message AgoraChat.ChatManager.ResendMessage ( string  messageId,
CallBack  callback = null 
)

重新发送指定消息。[作废]

异步方法。

参数
messageId重发消息的 ID。
callback重发结果回调,详见 CallBack
返回
重发的消息对象。

◆ SearchMsgFromDB()

List< Message > AgoraChat.ChatManager.SearchMsgFromDB ( string  keywords,
long  timestamp = 0,
int  maxCount = 20,
string  from = null,
MessageSearchDirection  direction = MessageSearchDirection.UP 
)

查询指定数量的本地消息。

注意

若查询消息数量较大,需考虑内存消耗,每次最多可查询 200 条消息。

参数
keywords查找关键字,字符串类型。
timestamp查询的 Unix 时间戳,单位为毫秒。
maxCount查询的最大消息数。
from消息来源,一般指会话 ID。
direction查询方向,详见 MessageSearchDirection
返回
消息列表。

◆ SendConversationReadAck()

void AgoraChat.ChatManager.SendConversationReadAck ( string  conversationId,
CallBack  callback = null 
)

发送会话的已读回执。

该方法通知服务器将此会话未读数设置为 0,消息发送方(包含多端多设备)将会收到 IChatManagerDelegate#OnConversationRead(string from, string to) 回调。

参数
conversationId会话 ID。
callback发送回执的结果回调,详见 CallBack

◆ SendMessage()

void AgoraChat.ChatManager.SendMessage ( ref Message  message,
CallBack  callback = null 
)

发送消息。

异步方法。

对于语音、图片等带有附件的消息,SDK 在默认情况下会自动上传附件。请参见 Options#ServerTransfer

参数
message要发送的消息对象,必填。
callback发送结果回调,详见 CallBack

◆ SendMessageReadAck()

void AgoraChat.ChatManager.SendMessageReadAck ( string  messageId,
CallBack  callback = null 
)

发送消息已读回执。

该方法会通知服务器将此消息置为已读,消息发送方(包含多端多设备)将会收到 IChatManagerDelegate#OnMessagesRead(List<Message>) 回调。

参数
messageId消息 ID。
callback发送回执的结果回调,详见 CallBack

◆ SendReadAckForGroupMessage()

void AgoraChat.ChatManager.SendReadAckForGroupMessage ( string  messageId,
string  ackContent,
CallBack  callback = null 
)

发送群消息已读回执。

前提条件:设置了 Options#RequireAck(boolean)Message#IsNeedGroupAck(boolean)

参考: 发送单聊消息已读回执,详见 SendMessageReadAck(String) ; 会话已读回执,详见 SendConversationReadAck(String)

参数
messageId消息 ID。
ackContent回执信息。ackContent 属性是用户自己定义的关键字,接收后,解析出自定义的字符串,可以自行处理。
callback发送回执的结果回调,详见 CallBack

◆ UpdateMessage()

bool AgoraChat.ChatManager.UpdateMessage ( Message  message)

更新本地消息。

该方法调用后,本地内存和数据库中的消息均更新。

参数
message要更新的消息对象。
返回
本地消息是否成功更新。
  • true:是;
  • false:否。

◆ ModifyMessage()

void AgoraChat.ChatManager.ModifyMessage ( string  messageId,
MessageBody.TextBody  body,
ValueCallBack< Message callback = null 
)

修改消息内容。

调用该方法修改消息内容后,本地和服务端的消息均会修改。

调用该方法只能修改单聊和群聊中的文本消息,不能修改聊天室消息。

参数
messageId要修改的消息的 ID。
body内容修改后的消息体。
callback完成的回调,详见 CallBack()

◆ RemoveMessagesBeforeTimestamp()

void AgoraChat.ChatManager.RemoveMessagesBeforeTimestamp ( long  timeStamp,
CallBack  callback = null 
)

将指定 Unix 时间戳之前收发的消息从本地内存和数据库中移除。

参数
timeStamp移除的 Unix 时间戳,单位为毫秒。
callback移除结果回调,详见 CallBack

◆ DeleteConversationFromServer()

void AgoraChat.ChatManager.DeleteConversationFromServer ( string  conversationId,
ConversationType  conversationType,
bool  isDeleteServerMessages,
CallBack  callback = null 
)

删除服务端的指定会话及其历史消息。

异步方法。

参数
conversationId会话 ID。
conversationType会话类型,详见 ConversationType
isDeleteServerMessages是否删除会话时同时删除相应的历史消息。
  • true:是。
  • false 是。
callback会话删除成功与否的回调,详见 CallBack

◆ FetchSupportLanguages()

void AgoraChat.ChatManager.FetchSupportLanguages ( ValueCallBack< List< SupportLanguage > >  callback = null)

获取翻译服务支持的语言。

参数
callBack完成的回调,详见 ValueCallBack()

◆ TranslateMessage()

void AgoraChat.ChatManager.TranslateMessage ( Message  message,
List< string >  targetLanguages,
ValueCallBack< Message callback = null 
)

翻译消息。

参数
message消息对象。
languages要翻译的目标语言 code 列表。
callback完成的回调,详见 CallBack()

◆ FetchGroupReadAcks()

void AgoraChat.ChatManager.FetchGroupReadAcks ( string  messageId,
string  groupId,
int  pageSize = 20,
string  startAckId = null,
ValueCallBack< CursorResult< GroupReadAck > >  callback = null 
)

从服务器获取群组消息回执详情。

分页获取。

参考: 发送群组消息回执,详见 SendReadAckForGroupMessage

异步方法。

参数
messageId消息 ID。
groupId群组 ID。
pageSize每页获取群消息已读回执的条数。
startAckId已读回执的 ID,如果为空,从最新的回执向前开始获取。
callBack结果回调,成功执行 ValueCallBack#onSuccess(Object),失败执行 ValueCallBack#onError(int, String)

◆ ReportMessage()

void AgoraChat.ChatManager.ReportMessage ( string  messageId,
string  tag,
string  reason,
CallBack  callback = null 
)

举报违规消息。

同步方法,会阻塞当前线程。

参数
messageId要举报的消息 ID。
tag非法消息的标签。你需要填写自定义标签,例如涉政广告
reason举报原因。你需要自行填写举报原因。
callBack完成的回调,详见 CallBack()

◆ AddReaction()

void AgoraChat.ChatManager.AddReaction ( string  messageId,
string  reaction,
CallBack  callback = null 
)

添加 Reaction。

异步方法。

参数
messageId消息 ID。
reaction消息 Reaction。
callback处理结果回调,详见 CallBack

◆ RemoveReaction()

void AgoraChat.ChatManager.RemoveReaction ( string  messageId,
string  reaction,
CallBack  callback = null 
)

删除 Reaction。

异步方法。

参数
messageId消息 ID。
reaction消息 Reaction。
callback处理结果回调,详见 CallBack

◆ GetReactionList()

void AgoraChat.ChatManager.GetReactionList ( List< string >  messageIdList,
MessageType  chatType,
string  groupId,
ValueCallBack< Dictionary< string, List< MessageReaction > > >  callback = null 
)

获取 Reaction 列表。

异步方法。

参数
messageIdList消息 ID。
chatType会话类型,仅支持单聊( ConversationType.Chat )和群聊(ConversationType.Group)。
groupId群组 ID,该参数只在群聊生效。
callback处理结果回调,包含消息 ID 对应的 Reaction 列表(EMMessageReaction 的用户列表为概要数据,只包含前三个用户信息)。

◆ GetReactionDetail()

void AgoraChat.ChatManager.GetReactionDetail ( string  messageId,
string  reaction,
string  cursor = null,
int  pageSize = 20,
ValueCallBack< CursorResult< MessageReaction > >  callback = null 
)

获取 Reaction 详细信息。

异步方法。

参数
messageId消息 ID。
reaction消息 Reaction。
cursor查询 cursor。
pageSize每页获取的 Reaction 条数。
callback处理结果回调,包含 cursor 和 MessageReaction 列表(仅使用该列表第一个数据即可)。

◆ GetConversationsFromServerWithPage()

void AgoraChat.ChatManager.GetConversationsFromServerWithPage ( int  pageNum,
int  pageSize,
ValueCallBack< List< Conversation > >  callback = null 
)

从服务器获取指定数目的会话对象。

未找到任何会话对象返回的列表为空。

参数
pageNum当前页码。
pageSize每页期望返回的会话数。
callback获取的会话列表,详见 ValueCallBack

◆ RemoveMessagesFromServer() [1/2]

void AgoraChat.ChatManager.RemoveMessagesFromServer ( string  conversationId,
ConversationType  conversationType,
List< string >  messageIdList,
CallBack  callback = null 
)

从会话中删除消息(包括本地存储和服务器存储)。

异步方法。

参数
conversationId会话 ID。
conversationType会话类型,详见 ConversationType
messageIdList要移除的消息的 ID 列表。
callback处理结果回调,详见 CallBack

◆ RemoveMessagesFromServer() [2/2]

void AgoraChat.ChatManager.RemoveMessagesFromServer ( string  conversationId,
ConversationType  conversationType,
long  timeStamp,
CallBack  callback = null 
)

从会话中删除消息(包括本地存储和服务器存储)。

异步方法。

参数
conversationId会话 ID。
conversationType会话类型,详见 ConversationType
timeStamp指定的时间戳, 单位为毫秒。该时间戳之前的消息会被删除。
callback处理结果回调,详见 CallBack

◆ PinConversation()

void AgoraChat.ChatManager.PinConversation ( string  conversationId,
bool  isPinned,
CallBack  callback = null 
)

设置会话是否置顶。

异步方法。

参数
conversationId会话 ID。
isPinned是否将会话设置为置顶。
callback处理结果回调,详见 CallBack

◆ FetchCombineMessageDetail()

void AgoraChat.ChatManager.FetchCombineMessageDetail ( Message  msg,
ValueCallBack< List< Message > >  callback = null 
)

获取并解析合并消息。

参数
msg需要获取和解析的合并消息。
callback成功返回合并消息中的消息列表,失败返回错误原因,详见 ValueCallBack

◆ AddChatManagerDelegate()

void AgoraChat.ChatManager.AddChatManagerDelegate ( IChatManagerDelegate  chatManagerDelegate)

注册聊天管理器的监听器。

参数
chatManagerDelegate要注册的聊天管理器的监听器,继承自 IChatManagerDelegate

◆ RemoveChatManagerDelegate()

void AgoraChat.ChatManager.RemoveChatManagerDelegate ( IChatManagerDelegate  chatManagerDelegate)

移除聊天管理器的监听器。

参数
chatManagerDelegate要移除的聊天管理器的监听器,继承自 IChatManagerDelegate