public class LCIMConversation extends Object
Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<String,cn.leancloud.ops.ObjectFieldOperation> |
operations |
Modifier | Constructor and Description |
---|---|
protected |
LCIMConversation(LCIMClient client,
List<String> members,
Map<String,Object> attributes,
boolean isTransient) |
protected |
LCIMConversation(LCIMClient client,
String conversationId) |
Modifier and Type | Method and Description |
---|---|
void |
addMembers(List<String> memberIds,
LCIMOperationPartiallySucceededCallback callback)
在聊天对话中间增加新的参与者
|
protected void |
addNewOperation(cn.leancloud.ops.ObjectFieldOperation op) |
void |
addToLocalCache(LCIMMessage message)
save local message which failed to send to LeanCloud server.
|
void |
blockMembers(List<String> memberIds,
LCIMOperationPartiallySucceededCallback callback)
将部分成员加入黑名单
|
Map<String,Object> |
dumpRawData() |
void |
fetchInfoInBackground(LCIMConversationCallback callback)
Fetch info in async mode.
|
void |
fetchReceiptTimestamps(LCIMConversationCallback callback)
fetchReceiptTimestamps
|
Object |
get(String key)
Access a value
|
void |
getAllMemberInfo(int offset,
int limit,
LCIMConversationMemberQueryCallback callback)
获取当前对话的所有角色信息
|
Object |
getAttribute(String key)
Deprecated.
Please use
get(String) |
Map<String,Object> |
getAttributes()
Return all attributes.
|
String |
getConversationId()
get conversation id
|
Date |
getCreatedAt()
获取Conversation的创建时间
|
String |
getCreator()
获取聊天对话的创建者
|
Map<String,Object> |
getFetchRequestParams() |
long |
getLastDeliveredAt()
get the latest deliveredAt timestamp
|
LCIMMessage |
getLastMessage()
获取最新一条消息的时间
|
Date |
getLastMessageAt()
获取最新一条消息的时间
|
long |
getLastReadAt()
get the latest readAt timestamp
|
void |
getMemberCount(LCIMConversationMemberCountCallback callback)
查询成员数量
|
void |
getMemberInfo(String memberId,
LCIMConversationMemberQueryCallback callback)
获取对话内指定成员的角色信息
|
List<String> |
getMembers()
获取conversation当前的参与者
|
String |
getName()
获取conversation的名字
|
int |
getTemporaryExpiredat()
获取临时对话过期时间(以秒为单位)
|
int |
getType() |
String |
getUniqueId() |
int |
getUnreadMessagesCount()
获取当前未读消息数量
|
Date |
getUpdatedAt()
获取Conversation的更新时间
|
boolean |
isShouldFetch()
判断当前 Conversation 是否有效,因为 IMConversation 为客户端创建,有可能因为没有同步造成数据丢失
可以根据此函数来判断,如果无效,则需要调用 fetchInfoInBackground 同步数据
如果 fetchInfoInBackground 出错(比如因为 acl 问题造成 Forbidden to find by class permissions ),
客户端就会在收到消息后一直做 fetch 操作,所以这里加了一个判断,如果在 FETCH_TIME_INTERVEL 内有业务类型的
error code 返回,则不在请求
|
boolean |
isSystem()
是否是服务号
|
boolean |
isTemporary()
是否是临时对话
|
boolean |
isTransient() |
boolean |
isUnique() |
void |
join(LCIMConversationCallback callback)
加入当前聊天对话
|
void |
kickMembers(List<String> memberIds,
LCIMOperationPartiallySucceededCallback callback)
在聊天对话中间踢掉部分参与者
|
void |
mute(LCIMConversationCallback callback)
静音,客户端拒绝收到服务器端的离线推送通知
|
void |
muteMembers(List<String> memberIds,
LCIMOperationPartiallySucceededCallback callback)
将部分成员禁言
|
static LCIMConversation |
parseFromJson(LCIMClient client,
Map<String,Object> jsonObj)
parse LCIMConversation from jsonObject
|
LCIMException |
processQueryResult(String result) |
void |
queryBlockedMembers(int offset,
int limit,
LCIMConversationSimpleResultCallback callback)
查询黑名单的成员列表
|
void |
queryBlockedMembers(int limit,
String next,
LCIMConversationIterableResultCallback callback)
查询黑名单的成员列表
|
void |
queryMessages(int limit,
LCIMMessagesQueryCallback callback)
获取最新的消息记录
|
void |
queryMessages(LCIMMessageInterval interval,
LCIMMessageQueryDirection direction,
int limit,
LCIMMessagesQueryCallback callback)
根据指定的区间来查询历史消息,可以指定区间开闭、查询方向以及最大条目限制
|
void |
queryMessages(LCIMMessagesQueryCallback callback)
查询最近的20条消息记录
|
void |
queryMessages(String msgId,
long timestamp,
int limit,
LCIMMessagesQueryCallback callback)
查询消息记录,上拉时使用。
|
void |
queryMessagesByType(int msgType,
int limit,
LCIMMessagesQueryCallback callback)
获取特停类型的历史消息。
注意:这个操作总是会从云端获取记录。
另,该函数和 queryMessagesByType(type, msgId, timestamp, limit, callback) 配合使用可以实现翻页效果。
|
void |
queryMessagesByType(int msgType,
String msgId,
long timestamp,
int limit,
LCIMMessagesQueryCallback callback)
获取特定类型的历史消息。
注意:这个操作总是会从云端获取记录。
另,如果不指定 msgId 和 timestamp,则该函数效果等同于 queryMessageByType(type, limit, callback)
|
void |
queryMessagesFromCache(int limit,
LCIMMessagesQueryCallback callback)
从本地缓存中拉取消息
|
void |
queryMessagesFromServer(int limit,
LCIMMessagesQueryCallback callback)
从服务器端拉取最新消息
|
void |
queryMutedMembers(int offset,
int limit,
LCIMConversationSimpleResultCallback callback)
查询被禁言的成员列表
|
void |
queryMutedMembers(int limit,
String next,
LCIMConversationIterableResultCallback callback)
查询被禁言的成员列表
|
void |
quit(LCIMConversationCallback callback)
退出当前的聊天对话
|
void |
read()
清除未读消息
|
void |
recallMessage(LCIMMessage message,
LCIMMessageRecalledCallback callback)
racall message
|
void |
remove(String key) |
void |
removeFromLocalCache(LCIMMessage message)
remove local message from cache.
|
void |
sendMessage(LCIMMessage message,
LCIMConversationCallback callback)
发送一条非暂存消息
|
void |
sendMessage(LCIMMessage message,
LCIMMessageOption messageOption,
LCIMConversationCallback callback)
发送一条消息。
|
void |
set(String key,
Object value)
Add a key-value pair to this conversation
|
void |
setAttribute(String key,
Object value)
Deprecated.
Please use
set(String, Object) |
void |
setAttributes(Map<String,Object> attr)
设置当前聊天对话的属性
|
protected void |
setConversationId(String id) |
protected void |
setCreator(String creator) |
protected void |
setMembers(List<String> m) |
void |
setMustFetch() |
void |
setName(String name) |
void |
setTemporaryExpiredat(long temporaryExpiredat)
设置临时对话过期时间(以秒为单位)
仅对 临时对话 有效
|
String |
toJSONString() |
String |
toString() |
void |
unblockMembers(List<String> memberIds,
LCIMOperationPartiallySucceededCallback callback)
将部分成员从黑名单移出来
|
void |
unmute(LCIMConversationCallback callback)
取消静音,客户端取消静音设置
|
void |
unmuteMembers(List<String> memberIds,
LCIMOperationPartiallySucceededCallback callback)
将部分成员解除禁言
|
boolean |
unreadMessagesMentioned()
判断当前未读消息中是否有提及当前用户的消息存在。
|
void |
updateFetchTimestamp(long timestamp) |
void |
updateInfoInBackground(LCIMConversationCallback callback)
更新当前对话的属性至服务器端
|
void |
updateMemberRole(String memberId,
ConversationMemberRole role,
LCIMConversationCallback callback)
更新成员的角色信息
|
void |
updateMessage(LCIMMessage oldMessage,
LCIMMessage newMessage,
LCIMMessageUpdatedCallback callback)
update message content
|
protected ConcurrentMap<String,cn.leancloud.ops.ObjectFieldOperation> operations
protected LCIMConversation(LCIMClient client, List<String> members, Map<String,Object> attributes, boolean isTransient)
protected LCIMConversation(LCIMClient client, String conversationId)
public boolean isSystem()
public boolean isTemporary()
public int getTemporaryExpiredat()
public void setTemporaryExpiredat(long temporaryExpiredat)
temporaryExpiredat
- expiration value.public boolean isTransient()
public Date getCreatedAt()
public Date getUpdatedAt()
public boolean isShouldFetch()
public void setMustFetch()
public void updateFetchTimestamp(long timestamp)
public int getType()
public boolean isUnique()
public String getUniqueId()
public String getConversationId()
protected void setConversationId(String id)
protected void setCreator(String creator)
public String getCreator()
public long getLastReadAt()
public long getLastDeliveredAt()
public void set(String key, Object value)
key
- Keys must be alphanumerical plus underscore, and start with a letter.value
- Values may be numerical, String, JSONObject, JSONArray, JSONObject.NULL, or other
LCObjects. value may not be null.public void remove(String key)
protected void addNewOperation(cn.leancloud.ops.ObjectFieldOperation op)
public Object get(String key)
key
- attribute keypublic Object getAttribute(String key)
get(String)
key
- attribute keypublic Map<String,Object> getAttributes()
public void setAttribute(String key, Object value)
set(String, Object)
key
- attribute keyvalue
- attribute value.public void setAttributes(Map<String,Object> attr)
attr
- attribute mappublic String getName()
public void setName(String name)
public Date getLastMessageAt()
public LCIMMessage getLastMessage()
public int getUnreadMessagesCount()
public boolean unreadMessagesMentioned()
public void sendMessage(LCIMMessage message, LCIMConversationCallback callback)
message
- message instance.callback
- callback function.public void sendMessage(LCIMMessage message, LCIMMessageOption messageOption, LCIMConversationCallback callback)
message
- message instance.messageOption
- 消息发送选项。callback
- callback function.public void updateMessage(LCIMMessage oldMessage, LCIMMessage newMessage, LCIMMessageUpdatedCallback callback)
oldMessage
- the message need to be modifiednewMessage
- the content of the old message will be covered by the new message'scallback
- callback function.public void recallMessage(LCIMMessage message, LCIMMessageRecalledCallback callback)
message
- the message need to be recalledcallback
- callback function.public void addToLocalCache(LCIMMessage message)
message
- the message need to be saved to local.public void removeFromLocalCache(LCIMMessage message)
message
- message instance.public void fetchReceiptTimestamps(LCIMConversationCallback callback)
callback
- callback function.public void queryMessages(LCIMMessagesQueryCallback callback)
callback
- callback function.public void queryMessagesFromServer(int limit, LCIMMessagesQueryCallback callback)
limit
- result size.callback
- callback function.public void queryMessagesFromCache(int limit, LCIMMessagesQueryCallback callback)
limit
- result size.callback
- callback function.public void queryMessagesByType(int msgType, int limit, LCIMMessagesQueryCallback callback)
msgType
- 消息类型,可以参看 `LCIMMessageType` 里的定义。limit
- 本批次希望获取的消息数量。callback
- 结果回调函数public void queryMessagesByType(int msgType, String msgId, long timestamp, int limit, LCIMMessagesQueryCallback callback)
msgType
- 消息类型,可以参看 `LCIMMessageType` 里的定义。msgId
- 消息id,从特定消息 id 开始向前查询(结果不会包含该记录)timestamp
- 查询起始的时间戳,返回小于这个时间的记录,必须配合 msgId 一起使用。
要从最新消息开始获取时,请用 0 代替客户端的本地当前时间(System.currentTimeMillis())limit
- 返回条数限制callback
- 结果回调函数public void queryMessages(int limit, LCIMMessagesQueryCallback callback)
limit
- result size.callback
- callback function.public void queryMessages(String msgId, long timestamp, int limit, LCIMMessagesQueryCallback callback)
msgId
- 消息id,从消息id开始向前查询timestamp
- 查询起始的时间戳,返回小于这个时间的记录。
客户端时间不可靠,请用 0 代替 System.currentTimeMillis()limit
- 返回条数限制callback
- callback function.public void queryMessages(LCIMMessageInterval interval, LCIMMessageQueryDirection direction, int limit, LCIMMessagesQueryCallback callback)
interval
- - 区间,由起止 MessageIntervalBound 组成direction
- - 查询方向,支持向前(LCIMMessageQueryDirection.DirectionFromNewToOld)
或向后(LCIMMessageQueryDirection.DirectionFromOldToNew)查询limit
- - 结果最大条目限制callback
- - 结果回调函数public void getAllMemberInfo(int offset, int limit, LCIMConversationMemberQueryCallback callback)
offset
- 查询结果的起始点limit
- 查询结果集上限callback
- 结果回调函数public void getMemberInfo(String memberId, LCIMConversationMemberQueryCallback callback)
memberId
- 成员的 clientidcallback
- 结果回调函数public void addMembers(List<String> memberIds, LCIMOperationPartiallySucceededCallback callback)
memberIds
- member id list.callback
- callback function.public void kickMembers(List<String> memberIds, LCIMOperationPartiallySucceededCallback callback)
memberIds
- member id list.callback
- callback function.public void updateMemberRole(String memberId, ConversationMemberRole role, LCIMConversationCallback callback)
memberId
- 成员的 client idrole
- 角色callback
- 结果回调函数public void muteMembers(List<String> memberIds, LCIMOperationPartiallySucceededCallback callback)
memberIds
- 成员列表callback
- 结果回调函数public void unmuteMembers(List<String> memberIds, LCIMOperationPartiallySucceededCallback callback)
memberIds
- 成员列表callback
- 结果回调函数public void queryMutedMembers(int offset, int limit, LCIMConversationSimpleResultCallback callback)
offset
- 查询结果的起始点limit
- 查询结果集上限callback
- 结果回调函数public void queryMutedMembers(int limit, String next, LCIMConversationIterableResultCallback callback)
limit
- 查询结果集上限next
- 查询结果的起始点callback
- 结果回调函数public void blockMembers(List<String> memberIds, LCIMOperationPartiallySucceededCallback callback)
memberIds
- 成员列表callback
- 结果回调函数public void unblockMembers(List<String> memberIds, LCIMOperationPartiallySucceededCallback callback)
memberIds
- 成员列表callback
- 结果回调函数public void queryBlockedMembers(int offset, int limit, LCIMConversationSimpleResultCallback callback)
offset
- 查询结果的起始点limit
- 查询结果集上限callback
- 结果回调函数public void queryBlockedMembers(int limit, String next, LCIMConversationIterableResultCallback callback)
limit
- 查询结果集上限next
- 查询结果的起始点callback
- 结果回调函数public void getMemberCount(LCIMConversationMemberCountCallback callback)
callback
- callback function.public void mute(LCIMConversationCallback callback)
callback
- callback function.public void unmute(LCIMConversationCallback callback)
callback
- callback function.public void quit(LCIMConversationCallback callback)
callback
- callback function.public void join(LCIMConversationCallback callback)
callback
- callback function.public void read()
public void updateInfoInBackground(LCIMConversationCallback callback)
callback
- callback function.public void fetchInfoInBackground(LCIMConversationCallback callback)
callback
- callback function.public static LCIMConversation parseFromJson(LCIMClient client, Map<String,Object> jsonObj)
client
- client instancejsonObj
- json objectpublic LCIMException processQueryResult(String result)
public String toJSONString()
Copyright © 2020, 美味书签(北京)信息技术有限公司 All rights reserved.