chore: 调整命名空间和目录结构

oneRain 2020-04-28 17:02:52 +08:00
parent 38287c9a9c
commit a06b836a10
19 changed files with 328 additions and 266 deletions

View File

@ -187,6 +187,7 @@ namespace LeanCloud.Realtime {
return;
}
await Client.MessageController.Read(Id, LastMessage);
Unread = 0;
}
/// <summary>

View File

@ -5,7 +5,7 @@ using System.Threading.Tasks;
using Google.Protobuf;
using LeanCloud.Realtime.Internal.Router;
using LeanCloud.Realtime.Internal.WebSocket;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
using LeanCloud.Common;
using LeanCloud.Storage;

View File

@ -2,7 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using LeanCloud.Common;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
namespace LeanCloud.Realtime.Internal.Connection {
/// <summary>

View File

@ -1,5 +1,5 @@
using System.Threading.Tasks;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
using LeanCloud.Realtime.Internal.Connection;
namespace LeanCloud.Realtime.Internal.Controller {

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Newtonsoft.Json;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
using LeanCloud.Storage.Internal;
using LeanCloud.Storage.Internal.Codec;
using LeanCloud.Common;
@ -552,7 +552,12 @@ namespace LeanCloud.Realtime.Internal.Controller {
if (errors != null) {
result.FailureList = new List<LCIMOperationFailure>();
foreach (ErrorCommand error in errors) {
result.FailureList.Add(new LCIMOperationFailure(error));
LCIMOperationFailure failure = new LCIMOperationFailure {
Code = error.Code,
Reason = error.Reason,
IdList = error.Pids?.ToList()
};
result.FailureList.Add(failure);
}
}
return result;
@ -597,6 +602,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
message.Id = conv.Mid;
message.FromClientId = conv.From;
message.SentTimestamp = conv.Timestamp;
message.Mentioned = conv.Mentioned;
conversation.LastMessage = message;
}
return conversation;

View File

@ -1,5 +1,5 @@
using System.Threading.Tasks;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
namespace LeanCloud.Realtime.Internal.Controller {
internal class LCIMGoAwayController : LCIMController {

View File

@ -4,7 +4,7 @@ using System.Threading.Tasks;
using System.Collections.ObjectModel;
using Newtonsoft.Json;
using Google.Protobuf;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
namespace LeanCloud.Realtime.Internal.Controller {
internal class LCIMMessageController : LCIMController {
@ -46,6 +46,19 @@ namespace LeanCloud.Realtime.Internal.Controller {
if (options.Will) {
direct.Will = options.Will;
}
// 推送数据
if (options.PushData != null) {
direct.PushData = JsonConvert.SerializeObject(options.PushData);
}
// 提醒所有人
if (message.MentionAll) {
direct.MentionAll = message.MentionAll;
}
// 提醒用户列表
if (message.MentionIdList != null &&
message.MentionIdList.Count > 0) {
direct.MentionPids.AddRange(message.MentionIdList);
}
GenericCommand command = NewCommand(CommandType.Direct);
command.DirectMessage = direct;
// 优先级
@ -177,6 +190,8 @@ namespace LeanCloud.Realtime.Internal.Controller {
message.PatchedTimestamp = item.PatchTimestamp;
message.MentionAll = item.MentionAll;
message.MentionIdList = item.MentionPids.ToList();
message.Mentioned = message.MentionAll ||
message.MentionIdList.Contains(Client.Id);
return message;
}).ToList().AsReadOnly();
}
@ -256,6 +271,8 @@ namespace LeanCloud.Realtime.Internal.Controller {
message.SentTimestamp = direct.Timestamp;
message.MentionAll = direct.MentionAll;
message.MentionIdList = direct.MentionPids.ToList();
message.Mentioned = message.MentionAll ||
message.MentionIdList.Contains(Client.Id);
message.PatchedTimestamp = direct.PatchTimestamp;
message.IsTransient = direct.Transient;
// 通知服务端已接收
@ -265,6 +282,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
}
// 获取对话
LCIMConversation conversation = await Client.GetOrQueryConversation(direct.Cid);
conversation.Unread++;
conversation.LastMessage = message;
Client.OnMessage?.Invoke(conversation, message);
}

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
namespace LeanCloud.Realtime.Internal.Controller {
internal class LCIMSessionController : LCIMController {

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Collections.ObjectModel;
using LeanCloud.Common;
using LeanCloud.Storage;
using LeanCloud.Realtime.Protocol;
using LeanCloud.Realtime.Internal.Protocol;
using LeanCloud.Realtime.Internal.Controller;
using LeanCloud.Realtime.Internal.Connection;

View File

@ -1,25 +0,0 @@
using System.Linq;
using System.Collections.Generic;
using LeanCloud.Realtime.Protocol;
namespace LeanCloud.Realtime {
public class LCIMOperationFailure {
public int Code {
get; set;
}
public string Reason {
get; set;
}
public List<string> MemberList {
get; set;
}
public LCIMOperationFailure(ErrorCommand error) {
Code = error.Code;
Reason = error.Reason;
MemberList = error.Pids.ToList();
}
}
}

View File

@ -1,4 +1,6 @@
namespace LeanCloud.Realtime {
using System.Collections.Generic;
namespace LeanCloud.Realtime {
/// <summary>
/// 消息优先级
/// </summary>
@ -40,6 +42,10 @@
get; set;
}
public Dictionary<string, object> PushData {
get; set;
}
public static LCIMMessageSendOptions Default = new LCIMMessageSendOptions();
}
}

View File

@ -23,5 +23,7 @@
<Folder Include="Signature\" />
<Folder Include="Internal\Controller\" />
<Folder Include="Internal\Connection\" />
<Folder Include="Internal\Protocol\" />
<Folder Include="Result\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,35 @@
using System.Collections.Generic;
namespace LeanCloud.Realtime {
/// <summary>
/// 操作失败
/// </summary>
public class LCIMOperationFailure {
/// <summary>
/// 失败码
/// </summary>
public int Code {
get; set;
}
/// <summary>
/// 失败原因
/// </summary>
public string Reason {
get; set;
}
/// <summary>
/// 失败数据
/// </summary>
public List<string> IdList {
get; set;
}
//public LCIMOperationFailure(ErrorCommand error) {
// Code = error.Code;
// Reason = error.Reason;
// MemberList = error.Pids.ToList();
//}
}
}

View File

@ -1,11 +1,20 @@
using System.Collections.ObjectModel;
namespace LeanCloud.Realtime {
/// <summary>
/// 查询分页结果
/// </summary>
public class LCIMPageResult {
/// <summary>
/// 当前分页数据集
/// </summary>
public ReadOnlyCollection<string> Results {
get; internal set;
}
/// <summary>
/// 下次请求的数据
/// </summary>
public string Next {
get; internal set;
}

View File

@ -1,13 +1,20 @@
using System;
using System.Collections.Generic;
using LeanCloud.Storage;
using System.Collections.Generic;
namespace LeanCloud.Realtime {
/// <summary>
/// 部分成功结果
/// </summary>
public class LCIMPartiallySuccessResult {
/// <summary>
/// 成功数据集
/// </summary>
public List<string> SuccessfulClientIdList {
get; internal set;
}
/// <summary>
/// 失败原因
/// </summary>
public List<LCIMOperationFailure> FailureList {
get; internal set;
}

View File

@ -2,6 +2,9 @@
using System.Threading.Tasks;
namespace LeanCloud.Realtime {
/// <summary>
/// 签名工程接口
/// </summary>
public interface ILCIMSignatureFactory {
/// <summary>
/// 登录签名

View File

@ -1 +1 @@
protoc --proto_path=. --csharp_out=. messages2.proto.orig
protoc --proto_path=. --csharp_out=../Internal/Protocol messages2.proto.orig

View File

@ -1,7 +1,7 @@
syntax = "proto2";
package push_server.messages2;
option csharp_namespace = "LeanCloud.Realtime.Protocol";
option csharp_namespace = "LeanCloud.Realtime.Internal.Protocol";
// note that this line will be removed by out build script until we
// finally upgraded to protobuffer 3