human: 如何处理七牛云的即时通讯BMXChatService

gpt: [即时通讯](https://developer.qiniu.com/IM) > API 文档 > [ANDROID
API](https://developer.qiniu.com/IM/api/8191/android-im-class-indexes) >
BMXChatService

#  BMXChatService

最近更新时间: 2022-07-22 22:44:26

class im.floo.floolib.BMXChatService

聊天Service

Index

字段

  * swigCMemOwn

方法

  * getCPtr
  * finalize
  * delete
  * sendMessage
  * resendMessage
  * recallMessage
  * forwardMessage
  * forwardMessage
  * ackMessage
  * ackMessageDelivered
  * ackPlayMessage
  * readCancel
  * readAllMessage
  * removeMessage
  * removeMessage
  * downloadThumbnail
  * downloadThumbnail
  * downloadAttachment
  * downloadAttachmentByUrl
  * cancelUploadAttachment
  * cancelDownloadAttachment
  * transferingNum
  * insertMessages
  * getMessage
  * deleteConversation
  * deleteConversation
  * openConversation
  * openConversation
  * attachmentDir
  * attachmentDirForConversation
  * getAllConversations
  * getAllConversationsUnreadCount
  * retrieveHistoryMessages
  * searchMessagesByKeyWords
  * searchMessagesByKeyWords
  * searchMessages
  * searchMessages
  * getGroupAckMessageUserIdList
  * getGroupAckMessageUnreadUserIdList
  * getGroupPlayAckMessageUserIdList
  * getGroupUnPlayAckMessageUserIdList
  * addChatListener
  * removeChatListener

字段

swigCMemOwn

  * protected transient boolean swigCMemOwn
  * 

方法

getCPtr

  * protected static long getCPtr(BMXChatService obj);
  * Returns long

finalize

  * @Override() protected void finalize();
  * Returns void

delete

  * public synchronized void delete();
  * Returns void

sendMessage

  * public void sendMessage(BMXMessage msg);
  * 发送消息，消息状态变化会通过listener通知

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

发送的消息

Returns void

resendMessage

  * public void resendMessage(BMXMessage msg);
  * 重新发送消息，消息状态变化会通过listener通知

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

重新发送的消息

Returns void

recallMessage

  * public void recallMessage(BMXMessage msg);
  * 撤回消息，消息状态变化会通过listener通知

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

撤回的消息

Returns void

forwardMessage

  * public BMXErrorCode forwardMessage(BMXMessageList list, BMXConversation to, BMXMessage newMsg);
  * 合并转发消息

Parameters

    * list: BMXMessageList 

转发的消息列表

    * to: [BMXConversation](https://developer.qiniu.com/IM/api/8207/bmx-conversation)

消息被转发到的会话

    * newMsg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

转发的消息列表合并后生成的新的单条转发消息

Returns BMXErrorCode

forwardMessage

  * public void forwardMessage(BMXMessage msg);
  * 简单转发消息，用户应当通过BMXMessage::createForwardMessage()先创建转发消息

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

转发的消息

Returns void

ackMessage

  * public void ackMessage(BMXMessage msg);
  * 发送已读回执

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要发送已读回执的消息

Returns void

ackMessageDelivered

  * public void ackMessageDelivered(BMXMessage msg);
  * 发送送达回执

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要发送送达回执的消息

Returns void

ackPlayMessage

  * public void ackPlayMessage(BMXMessage msg);
  * 发送已播放回执

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要发送已读回播放的消息

Returns void

readCancel

  * public void readCancel(BMXMessage msg);
  * 标记此消息为未读，该消息同步到当前用户的所有设备

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要发送消息已读取消的消息

Returns void

readAllMessage

  * public void readAllMessage(BMXMessage msg);
  * 标记此消息及之前全部消息为已读，该消息同步到当前用户的所有设备

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要标记为此消息以前全部消息为已读的消息

Returns void

removeMessage

  * public void removeMessage(BMXMessage msg, boolean synchronize);
  * 删除此消息，该消息同步到当前用户的其它设备

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要删除的消息

    * synchronize: boolean 

是否同步到其它设备，不同步的情况下只会删除本地存储的该条消息

Returns void

removeMessage

  * public void removeMessage(BMXMessage msg);
  * Returns void

downloadThumbnail

  * public void downloadThumbnail(BMXMessage msg, BMXChatService.ThumbnailStrategy strategy);
  * 下载缩略图，下载状态变化和进度通过listener通知 缩略图生成策略，1 - 第三方服务器生成， 2 - 本地服务器生成，默认值是 1。

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要下载缩略图的消息

    * strategy: ThumbnailStrategy 

缩略图生成策略，1 - 第三方服务器生成， 2 - 本地服务器生成，默认值是 1。

Returns void

downloadThumbnail

  * public void downloadThumbnail(BMXMessage msg);
  * Returns void

downloadAttachment

  * public void downloadAttachment(BMXMessage msg);
  * 下载附件，下载状态变化和进度通过listener通知

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要下载附件的消息

Returns void

downloadAttachmentByUrl

  * public void downloadAttachmentByUrl(long msgId, String url, String path);
  * 下载附件，下载状态变化和进度通过listener通知

Parameters

    * msgId: long 

需要下载附件的消息

    * url: String 

文件远程地址

    * path: String 

文件本地路径

Returns void

cancelUploadAttachment

  * public void cancelUploadAttachment(BMXMessage msg);
  * 取消上传附件

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要取消上传附件的消息

Returns void

cancelDownloadAttachment

  * public void cancelDownloadAttachment(BMXMessage msg);
  * 取消上传附件

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要取消上传附件的消息

Returns void

transferingNum

  * public int transferingNum();
  * 上传或下载中的文件数

Returns int

insertMessages

  * public BMXErrorCode insertMessages(BMXMessageList list);
  * 插入消息

Parameters

    * list: BMXMessageList 

插入消息列表

Returns BMXErrorCode

getMessage

  * public BMXMessage getMessage(long msgId);
  * 读取一条消息

Parameters

    * msgId: long 

需要获取消息的消息id

Returns [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

deleteConversation

  * public void deleteConversation(long conversationId, boolean synchronize);
  * 删除会话

Parameters

    * conversationId: long 

需要删除会话的会话id

    * synchronize: boolean 

是否同步删除其它设备该会话，默认为false，仅删除本设备会话

Returns void

deleteConversation

  * public void deleteConversation(long conversationId);
  * Returns void

openConversation

  * public BMXConversation openConversation(long conversationId, BMXConversation.Type type, boolean createIfNotExist);
  * 打开一个会话

Parameters

    * conversationId: long 

需要打开的会话的会话id

    * type: Type 

会话的类型，单聊还是群聊。

    * createIfNotExist: boolean 

会话不存在的情况下是否要创建本地会话，默认为创建

Returns [BMXConversation](https://developer.qiniu.com/IM/api/8207/bmx-
conversation)

openConversation

  * public BMXConversation openConversation(long conversationId, BMXConversation.Type type);
  * Returns [BMXConversation](https://developer.qiniu.com/IM/api/8207/bmx-conversation)

attachmentDir

  * public String attachmentDir();
  * 获取附件保存路径

Returns String

attachmentDirForConversation

  * public String attachmentDirForConversation(long conversationId);
  * 获取会话的附件保存路径

Parameters

    * conversationId: long 

需要获取会话附件路径的会话id

Returns String

getAllConversations

  * public BMXConversationList getAllConversations();
  * 获取所有会话

Returns BMXConversationList

getAllConversationsUnreadCount

  * public int getAllConversationsUnreadCount();
  * 获取所有会话的全部未读数（标记为屏蔽的个人和群组的未读数不统计在内）

Returns int

retrieveHistoryMessages

  * public BMXErrorCode retrieveHistoryMessages(BMXConversation conversation, long refMsgId, long size, BMXMessageList result);
  * 拉取历史消息

Parameters

    * conversation: [BMXConversation](https://developer.qiniu.com/IM/api/8207/bmx-conversation)

需要拉取历史消息的会话

    * refMsgId: long 

拉取会话消息的起始消息Id

    * size: long 

拉取的最大消息条数

    * result: BMXMessageList 

拉取操作获取的消息列表，外部初始化传入空列表。

Returns BMXErrorCode

searchMessagesByKeyWords

  * public BMXErrorCode searchMessagesByKeyWords(String keywords, long refTime, long size, BMXMessageListList result, BMXConversation.Direction arg4);
  * 搜索消息

Parameters

    * keywords: String 

搜索的关键字

    * refTime: long 

搜索消息的起始时间

    * size: long 

搜索的最大消息条数

    * result: BMXMessageListList 

搜索到的消息结果列表，外部初始化传入空列表。

    * arg4: Direction 

消息搜索方向，默认（Direction::Up）是从更早的消息中搜索

Returns BMXErrorCode

searchMessagesByKeyWords

  * public BMXErrorCode searchMessagesByKeyWords(String keywords, long refTime, long size, BMXMessageListList result);
  * Returns BMXErrorCode

searchMessages

  * public BMXErrorCode searchMessages(String keywords, long refTime, long size, BMXMessageListList result, BMXConversation.Direction arg4);
  * 搜索消息

Parameters

    * keywords: String 

搜索的关键字

    * refTime: long 

搜索消息的起始时间

    * size: long 

搜索的最大消息条数

    * result: BMXMessageListList 

搜索到的消息结果列表，外部初始化传入空列表。

    * arg4: Direction 

消息搜索方向，默认（Direction::Up）是从更早的消息中搜索

Returns BMXErrorCode

searchMessages

  * public BMXErrorCode searchMessages(String keywords, long refTime, long size, BMXMessageListList result);
  * Returns BMXErrorCode

getGroupAckMessageUserIdList

  * public BMXErrorCode getGroupAckMessageUserIdList(BMXMessage msg, ListOfLongLong groupMemberIdList);
  * 获取发送的群组消息已读用户id列表

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要获取已读用户id列表的消息

    * groupMemberIdList: ListOfLongLong 

对该条消息已读的用户id列表，初始传入为空列表

Returns BMXErrorCode

getGroupAckMessageUnreadUserIdList

  * public BMXErrorCode getGroupAckMessageUnreadUserIdList(BMXMessage msg, ListOfLongLong groupMemberIdList);
  * 获取发送的群组消息未读用户id列表

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要获取未读用户id列表的消息

    * groupMemberIdList: ListOfLongLong 

对该条消息未读的用户id列表，初始传入为空列表

Returns BMXErrorCode

getGroupPlayAckMessageUserIdList

  * public BMXErrorCode getGroupPlayAckMessageUserIdList(BMXMessage msg, ListOfLongLong groupMemberIdList);
  * 获取发送的群组消息已播放用户id列表

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要获取已播放用户id列表的消息

    * groupMemberIdList: ListOfLongLong 

对该条消息已播放的用户id列表，初始传入为空列表

Returns BMXErrorCode

getGroupUnPlayAckMessageUserIdList

  * public BMXErrorCode getGroupUnPlayAckMessageUserIdList(BMXMessage msg, ListOfLongLong groupMemberIdList);
  * 获取发送的群组消息未播放用户id列表

Parameters

    * msg: [BMXMessage](https://developer.qiniu.com/IM/api/8239/bmxmessage)

需要获取未播放用户id列表的消息

    * groupMemberIdList: ListOfLongLong 

对该条消息未播放的用户id列表，初始传入为空列表

Returns BMXErrorCode

addChatListener

  * public void addChatListener(BMXChatServiceListener listener);
  * 添加聊天监听者

Parameters

    * listener: [BMXChatServiceListener](https://developer.qiniu.com/IM/api/8197/bmxchatservicelistener)

聊天监听者

Returns void

removeChatListener

  * public void removeChatListener(BMXChatServiceListener listener);
  * 移除聊天监听者

Parameters

    * listener: [BMXChatServiceListener](https://developer.qiniu.com/IM/api/8197/bmxchatservicelistener)

聊天监听者

Returns void

以上内容是否对您有帮助？