* LCIMChatRoom.cs:
* LCIMConversation.cs: * LCIMConversationQuery.cs: * LCIMServiceConversation.cs: * LCIMTemporaryConversation.cs: * LCIMConversationController.cs: chore: 完善对话的接口
parent
d6411d8b0d
commit
99975d9f7f
|
@ -1,18 +1,36 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 聊天室
|
||||
/// </summary>
|
||||
public class LCIMChatRoom : LCIMConversation {
|
||||
public LCIMChatRoom(LCIMClient client) :
|
||||
base(client) {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取在线用户数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetOnlineMembersCount() {
|
||||
return await GetMembersCount();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取在线用户
|
||||
/// </summary>
|
||||
/// <param name="limit"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ReadOnlyCollection<string>> GetOnlineMembers(int limit = 50) {
|
||||
return await Client.ConversationController.GetOnlineMembers(Id, limit);
|
||||
}
|
||||
|
||||
public override Task<LCIMPartiallySuccessResult> AddMembers(IEnumerable<string> clientIds) {
|
||||
throw new Exception("Add members is not allowed in chat room.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace LeanCloud.Realtime {
|
|||
/// </summary>
|
||||
/// <param name="clientIds">用户 Id</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPartiallySuccessResult> AddMembers(IEnumerable<string> clientIds) {
|
||||
public virtual async Task<LCIMPartiallySuccessResult> AddMembers(IEnumerable<string> clientIds) {
|
||||
if (clientIds == null || clientIds.Count() == 0) {
|
||||
throw new ArgumentNullException(nameof(clientIds));
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace LeanCloud.Realtime {
|
|||
get; private set;
|
||||
}
|
||||
|
||||
private LCIMClient client;
|
||||
private readonly LCIMClient client;
|
||||
|
||||
public LCIMConversationQuery(LCIMClient client) {
|
||||
Condition = new LCCompositionalCondition();
|
||||
|
|
|
@ -2,8 +2,23 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 系统对话
|
||||
/// </summary>
|
||||
public class LCIMServiceConversation : LCIMConversation {
|
||||
public LCIMServiceConversation(LCIMClient client) : base(client) {
|
||||
}
|
||||
|
||||
public async Task Subscribe() {
|
||||
await Join();
|
||||
}
|
||||
|
||||
public async Task Unsubscribe() {
|
||||
await Quit();
|
||||
}
|
||||
|
||||
public async Task<bool> CheckSubscription() {
|
||||
return await Client.ConversationController.CheckSubscription(Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
using System;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 临时对话
|
||||
/// </summary>
|
||||
public class LCIMTemporaryConversation : LCIMConversation {
|
||||
/// <summary>
|
||||
/// 过期时间
|
||||
/// </summary>
|
||||
public DateTime ExpiredAt {
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否过期
|
||||
/// </summary>
|
||||
public bool IsExpired {
|
||||
get {
|
||||
return DateTime.Now > ExpiredAt;
|
||||
|
|
|
@ -521,6 +521,25 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return members;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询是否订阅
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> CheckSubscription(string convId) {
|
||||
ConvCommand conv = new ConvCommand();
|
||||
conv.Cids.Add(convId);
|
||||
GenericCommand request = NewCommand(CommandType.Conv, OpType.IsMember);
|
||||
request.ConvMessage = conv;
|
||||
GenericCommand response = await Client.Connection.SendRequest(request);
|
||||
JsonObjectMessage jsonObj = response.ConvMessage.Results;
|
||||
Dictionary<string, object> result = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonObj.Data);
|
||||
if (result.TryGetValue(convId, out object obj)) {
|
||||
return (bool)obj;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private LCIMPartiallySuccessResult NewPartiallySuccessResult(IEnumerable<string> succesfulIds,
|
||||
IEnumerable<ErrorCommand> errors) {
|
||||
LCIMPartiallySuccessResult result = new LCIMPartiallySuccessResult {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
using System;
|
||||
namespace Realtime.Test {
|
||||
public class LocalSignatureFactory {
|
||||
public LocalSignatureFactory() {
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue