|
Chat SDK for Unity and Windows v1.3.2
|
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) |
| void | GetConversationsFromServerWithCursor (MarkType mark, string cursor="", int limit=20, ValueCallBack< CursorResult< Conversation > > callback=null) |
| int | GetUnreadMessageCount () |
| void | GetMessageCount (ValueCallBack< int > callback=null) |
| void | ImportMessages (List< Message > messages, CallBack callback=null) |
| List< Conversation > | LoadAllConversations () |
| Message | LoadMessage (string messageId) |
| bool | MarkAllConversationsAsRead () |
| void | RecallMessage (string messageId, string ext, CallBack callback=null) |
| Message | ResendMessage (string messageId, CallBack callback=null) |
| void | SearchMsgFromDB (string keywords, long timestamp=0, int maxCount=20, string from=null, MessageSearchDirection direction=MessageSearchDirection.UP, ValueCallBack< List< Message > > callback=null) |
| void | SearchMsgFromDB (string keywords, long timestamp=0, int maxCount=20, string from=null, MessageSearchDirection direction=MessageSearchDirection.UP, MessageSearchScope scope=MessageSearchScope.CONTENT, ValueCallBack< List< Message > > callback=null) |
| 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 | MarkConversations (List< string > conversationIds, bool isMarked, MarkType mark, CallBack callback=null) |
| void | DeleteAllMessagesAndConversations (bool clearServerData, CallBack callback=null) |
| void | PinMessage (string messageId, bool isPinned, CallBack callback=null) |
| void | GetPinnedMessagesFromServer (string conversationId, ValueCallBack< List< Message > > callback=null) |
| void | AddChatManagerDelegate (IChatManagerDelegate chatManagerDelegate) |
| void | RemoveChatManagerDelegate (IChatManagerDelegate chatManagerDelegate) |
| bool AgoraChat.ChatManager.DeleteConversation | ( | string | conversationId, |
| bool | deleteMessages = true |
||
| ) |
删除本地数据库中的指定会话及其历史消息。
若将 deleteMessages 设置为 true,删除会话的同时也会删除该会话的本地历史消息。
| conversationId | 会话 ID。 |
| deleteMessages | 是否同时删除本地历史消息:
|
| isThread | 删除会话是否是子区会话。
|
true :是;false :否。 | void AgoraChat.ChatManager.DownloadAttachment | ( | string | messageId, |
| CallBack | callback = null |
||
| ) |
| void AgoraChat.ChatManager.DownloadThumbnail | ( | string | messageId, |
| CallBack | callback = null |
||
| ) |
下载消息的缩略图。
若消息缩略图自动下载失败,也可以调用该方法下载。
| messageId | 要下载缩略图的消息 ID,一般图片消息和视频消息有缩略图。 |
| callback | 下载结果回调,详见 CallBack。 |
| 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 | 结果回调,返回消息列表。 |
| 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 | 结果回调,返回消息列表。 |
| Conversation AgoraChat.ChatManager.GetConversation | ( | string | conversationId, |
| ConversationType | type = ConversationType.Chat, |
||
| bool | createIfNeed = true |
||
| ) |
获取本地指定会话对象。
| conversationId | 会话 ID。 |
| type | 会话类型,详见 ConversationType。 |
| createIfNeed | 本地数据库中未找到相应会话时是否自动创建。
|
| isThread | 获取会话是否是子区会话。
|
| Conversation AgoraChat.ChatManager.GetThreadConversation | ( | string | threadId | ) |
获取本地指定子区会话对象。
| threadId | 子区 ID。 |
| void AgoraChat.ChatManager.GetConversationsFromServer | ( | ValueCallBack< List< Conversation > > | callback = null | ) |
| void AgoraChat.ChatManager.GetConversationsFromServerWithCursor | ( | bool | pinOnly, |
| string | cursor = "", |
||
| int | limit = 20, |
||
| ValueCallBack< CursorResult< Conversation > > | callback = null |
||
| ) |
根据指定参数从服务器获取相关会话对象。
| pinOnly | 是否只获取置顶会话:
|
| cursor | 开始获取数据的游标位置。 |
| limit | 每页返回的会话数。取值范围为 [1,50]。 |
| callback | 获取的会话列表,详见 ValueCallBack。 |
| void AgoraChat.ChatManager.GetConversationsFromServerWithCursor | ( | MarkType | mark, |
| string | cursor = "", |
||
| int | limit = 20, |
||
| ValueCallBack< CursorResult< Conversation > > | callback = null |
||
| ) |
根据标记等参数从服务器获取相关会话对象。
| mark: | 会话标记。 |
| cursor | 开始获取数据的游标位置。 |
| limit | 每页返回的会话数。取值范围为 [1,50]。 |
| callback | 获取的会话列表,详见 ValueCallBack。 |
| int AgoraChat.ChatManager.GetUnreadMessageCount | ( | ) |
获取未读消息数。
| void AgoraChat.ChatManager.GetMessageCount | ( | ValueCallBack< int > | callback = null | ) |
将消息导入本地数据库。
你只能将你发送或接受的消息导入本地数据库。
| messages | 要导入数据库的消息。 |
true: 成功;false: 失败。 | List< Conversation > AgoraChat.ChatManager.LoadAllConversations | ( | ) |
将本地数据库中的所有会话加载到内存。
一般情况下,该方法在成功登录后调用,以提升会话列表的加载速度。
| Message AgoraChat.ChatManager.LoadMessage | ( | string | messageId | ) |
将本地数据库中的指定消息加载到内存。
| messageId | 需加载的消息的 ID。 |
| bool AgoraChat.ChatManager.MarkAllConversationsAsRead | ( | ) |
将本地所有会话设置为已读。
true:是;false:否。 | void AgoraChat.ChatManager.RecallMessage | ( | string | messageId, |
| string | ext, | ||
| CallBack | callback = null |
||
| ) |
| void AgoraChat.ChatManager.SearchMsgFromDB | ( | string | keywords, |
| long | timestamp = 0, |
||
| int | maxCount = 20, |
||
| string | from = null, |
||
| MessageSearchDirection | direction = MessageSearchDirection.UP, |
||
| ValueCallBack< List< Message > > | callback = null |
||
| ) |
查询指定数量的本地消息。
注意
若查询消息数量较大,需考虑内存消耗,每次最多可查询 200 条消息。
| keywords | 查找关键字,字符串类型。 |
| timestamp | 查询的起始时间戳,单位为毫秒。 |
| maxCount | 查询的最大消息数。 |
| from | 消息发送方的用户 ID。若不设置该参数,SDK 搜索消息时会忽略该参数。 |
| direction | 查询方向,详见 MessageSearchDirection。 |
| callback | 成功返回合并消息中的消息列表,失败返回错误原因,详见 ValueCallBack。 |
| void AgoraChat.ChatManager.SearchMsgFromDB | ( | string | keywords, |
| long | timestamp = 0, |
||
| int | maxCount = 20, |
||
| string | from = null, |
||
| MessageSearchDirection | direction = MessageSearchDirection.UP, |
||
| MessageSearchScope | scope = MessageSearchScope.CONTENT, |
||
| ValueCallBack< List< Message > > | callback = null |
||
| ) |
基于消息范围查询指定数量的本地消息。
注意
若查询消息数量较大,需考虑内存消耗,每次最多可查询 200 条消息。
| keywords | 查找关键字,字符串类型。 |
| timestamp | 查询的起始时间戳,单位为毫秒。 |
| maxCount | 查询的最大消息数。 |
| from | 消息发送方的用户 ID。若不设置该参数,SDK 搜索消息时会忽略该参数。 |
| direction | 查询方向,详见 MessageSearchDirection。 |
| scope | 查询范围,详见 MessageSearchScope。 |
| callback | 成功返回合并消息中的消息列表,失败返回错误原因,详见 ValueCallBack。 |
| void AgoraChat.ChatManager.SendConversationReadAck | ( | string | conversationId, |
| CallBack | callback = null |
||
| ) |
发送会话的已读回执。
该方法通知服务器将此会话未读数设置为 0,消息发送方(包含多端多设备)将会收到 IChatManagerDelegate#OnConversationRead(string from, string to) 回调。
| conversationId | 会话 ID。 |
| callback | 发送回执的结果回调,详见 CallBack。 |
发送消息。
异步方法。
对于语音、图片等带有附件的消息,SDK 在默认情况下会自动上传附件。请参见 Options#ServerTransfer。
| message | 要发送的消息对象,必填。 |
| callback | 发送结果回调,详见 CallBack。 |
| void AgoraChat.ChatManager.SendMessageReadAck | ( | string | messageId, |
| CallBack | callback = null |
||
| ) |
发送单聊消息已读回执。
该方法会通知服务器将此消息置为已读,消息发送方(包含多端多设备)将会收到 IChatManagerDelegate#OnMessagesRead(List<Message>) 回调。
| messageId | 消息 ID。 |
| callback | 发送回执的结果回调,详见 CallBack。 |
| 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。 |
| bool AgoraChat.ChatManager.UpdateMessage | ( | Message | message | ) |
更新本地消息。
该方法调用后,本地内存和数据库中的消息均更新。
| message | 要更新的消息对象。 |
true:是;false:否。 | void AgoraChat.ChatManager.ModifyMessage | ( | string | messageId, |
| MessageBody.TextBody | body, | ||
| ValueCallBack< Message > | callback = null |
||
| ) |
修改消息内容。
调用该方法修改消息内容后,本地和服务端的消息均会修改。
调用该方法只能修改单聊和群聊中的文本消息,不能修改聊天室消息。
| messageId | 要修改的消息的 ID。 |
| body | 内容修改后的消息体。 |
| callback | 完成的回调,详见 CallBack()。 |
| void AgoraChat.ChatManager.RemoveMessagesBeforeTimestamp | ( | long | timeStamp, |
| CallBack | callback = null |
||
| ) |
将指定 Unix 时间戳之前收发的消息从本地内存和数据库中移除。
| timeStamp | 移除的 Unix 时间戳,单位为毫秒。 |
| callback | 移除结果回调,详见 CallBack。 |
| void AgoraChat.ChatManager.DeleteConversationFromServer | ( | string | conversationId, |
| ConversationType | conversationType, | ||
| bool | isDeleteServerMessages, | ||
| CallBack | callback = null |
||
| ) |
删除服务端的指定会话及其历史消息。
异步方法。
| conversationId | 会话 ID。 |
| conversationType | 会话类型,详见 ConversationType。 |
| isDeleteServerMessages | 是否删除会话时同时删除相应的历史消息。
|
| callback | 会话删除成功与否的回调,详见 CallBack。 |
| void AgoraChat.ChatManager.FetchSupportLanguages | ( | ValueCallBack< List< SupportLanguage > > | callback = null | ) |
获取翻译服务支持的语言。
| callBack | 完成的回调,详见 ValueCallBack()。 |
| void AgoraChat.ChatManager.TranslateMessage | ( | Message | message, |
| List< string > | targetLanguages, | ||
| ValueCallBack< Message > | callback = null |
||
| ) |
翻译消息。
| message | 消息对象。 |
| languages | 要翻译的目标语言 code 列表。 |
| callback | 完成的回调,详见 CallBack()。 |
| 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 | 每页获取群消息已读回执的条数。取值范围[1,50]。 |
| startAckId | 已读回执的 ID,如果为空,从最新的回执向前开始获取。 |
| callBack | 结果回调,成功执行 ValueCallBack#onSuccess(Object),失败执行 ValueCallBack#onError(int, String)。 |
| void AgoraChat.ChatManager.ReportMessage | ( | string | messageId, |
| string | tag, | ||
| string | reason, | ||
| CallBack | callback = null |
||
| ) |
举报违规消息。
同步方法,会阻塞当前线程。
| messageId | 要举报的消息 ID。 |
| tag | 非法消息的标签。你需要填写自定义标签,例如涉政或广告。 |
| reason | 举报原因。你需要自行填写举报原因。 |
| callBack | 完成的回调,详见 CallBack()。 |
| void AgoraChat.ChatManager.AddReaction | ( | string | messageId, |
| string | reaction, | ||
| CallBack | callback = null |
||
| ) |
| void AgoraChat.ChatManager.RemoveReaction | ( | string | messageId, |
| string | reaction, | ||
| CallBack | callback = null |
||
| ) |
| 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 的用户列表为概要数据,只包含前三个用户信息)。 |
| 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 列表(仅使用该列表第一个数据即可)。 |
| void AgoraChat.ChatManager.GetConversationsFromServerWithPage | ( | int | pageNum, |
| int | pageSize, | ||
| ValueCallBack< List< Conversation > > | callback = null |
||
| ) |
从服务器获取指定数目的会话对象。
未找到任何会话对象返回的列表为空。
| pageNum | 当前页码。 |
| pageSize | 每页期望返回的会话数。 |
| callback | 获取的会话列表,详见 ValueCallBack。 |
| void AgoraChat.ChatManager.RemoveMessagesFromServer | ( | string | conversationId, |
| ConversationType | conversationType, | ||
| List< string > | messageIdList, | ||
| CallBack | callback = null |
||
| ) |
从会话中删除消息(包括本地存储和服务器存储)。
异步方法。
| conversationId | 会话 ID。 |
| conversationType | 会话类型,详见 ConversationType。 |
| messageIdList | 要移除的消息的 ID 列表。 |
| callback | 处理结果回调,详见 CallBack。 |
| void AgoraChat.ChatManager.RemoveMessagesFromServer | ( | string | conversationId, |
| ConversationType | conversationType, | ||
| long | timeStamp, | ||
| CallBack | callback = null |
||
| ) |
从会话中删除消息(包括本地存储和服务器存储)。
异步方法。
| conversationId | 会话 ID。 |
| conversationType | 会话类型,详见 ConversationType。 |
| timeStamp | 指定的时间戳, 单位为毫秒。该时间戳之前的消息会被删除。 |
| callback | 处理结果回调,详见 CallBack。 |
| void AgoraChat.ChatManager.PinConversation | ( | string | conversationId, |
| bool | isPinned, | ||
| CallBack | callback = null |
||
| ) |
| void AgoraChat.ChatManager.FetchCombineMessageDetail | ( | Message | msg, |
| ValueCallBack< List< Message > > | callback = null |
||
| ) |
获取并解析合并消息。
| msg | 需要获取和解析的合并消息。 |
| callback | 成功返回合并消息中的消息列表,失败返回错误原因,详见 ValueCallBack。 |
| void AgoraChat.ChatManager.MarkConversations | ( | List< string > | conversationIds, |
| bool | isMarked, | ||
| MarkType | mark, | ||
| CallBack | callback = null |
||
| ) |
标记会话或移除会话标记。
异步方法。
调用该方法会同时为本地和服务器端的会话添加标记。
| conversationIds | 会话 ID 列表。 |
| isMarked | 添加或者移除标记:
|
| mark | 添加或移除的会话标记。 |
| callback | 处理结果回调,详见 CallBack。 |
| void AgoraChat.ChatManager.DeleteAllMessagesAndConversations | ( | bool | clearServerData, |
| CallBack | callback = null |
||
| ) |
清空所有会话及其消息。
异步方法。
| clearServerData | 是否删除服务端所有会话及其消息:
|
| callback | 处理结果回调,详见 CallBack。 |
| void AgoraChat.ChatManager.PinMessage | ( | string | messageId, |
| bool | isPinned, | ||
| CallBack | callback = null |
||
| ) |
消息置顶或取消置顶。
异步方法。
| messageId | 置顶或取消置顶的消息 ID。 |
| isPinned | 是否置顶消息:
|
| callback | 处理结果回调,详见 CallBack。 |
| void AgoraChat.ChatManager.GetPinnedMessagesFromServer | ( | string | conversationId, |
| ValueCallBack< List< Message > > | callback = null |
||
| ) |
从服务端获取指定会话的置顶消息列表。
| conversationId | 会话 ID。 |
| callback | 成功返回合并消息中的消息列表,失败返回错误原因,详见 ValueCallBack。 |
| void AgoraChat.ChatManager.AddChatManagerDelegate | ( | IChatManagerDelegate | chatManagerDelegate | ) |
注册聊天管理器的监听器。
| chatManagerDelegate | 要注册的聊天管理器的监听器,继承自 IChatManagerDelegate。 |
| void AgoraChat.ChatManager.RemoveChatManagerDelegate | ( | IChatManagerDelegate | chatManagerDelegate | ) |
移除聊天管理器的监听器。
| chatManagerDelegate | 要移除的聊天管理器的监听器,继承自 IChatManagerDelegate。 |