diff --git a/Realtime/Internal/Connection/LCConnection.cs b/Realtime/Internal/Connection/LCConnection.cs index bef04cf..1a3e092 100644 --- a/Realtime/Internal/Connection/LCConnection.cs +++ b/Realtime/Internal/Connection/LCConnection.cs @@ -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; diff --git a/Realtime/Internal/Connection/LCHeartBeat.cs b/Realtime/Internal/Connection/LCHeartBeat.cs index fa343d5..fbaf599 100644 --- a/Realtime/Internal/Connection/LCHeartBeat.cs +++ b/Realtime/Internal/Connection/LCHeartBeat.cs @@ -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 { /// diff --git a/Realtime/Internal/Controller/LCIMController.cs b/Realtime/Internal/Controller/LCIMController.cs index 4a1e4dc..598a526 100644 --- a/Realtime/Internal/Controller/LCIMController.cs +++ b/Realtime/Internal/Controller/LCIMController.cs @@ -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 { diff --git a/Realtime/Internal/Controller/LCIMConversationController.cs b/Realtime/Internal/Controller/LCIMConversationController.cs index 4bd5499..cd7836a 100644 --- a/Realtime/Internal/Controller/LCIMConversationController.cs +++ b/Realtime/Internal/Controller/LCIMConversationController.cs @@ -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(); 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; diff --git a/Realtime/Internal/Controller/LCIMGoAwayController.cs b/Realtime/Internal/Controller/LCIMGoAwayController.cs index 81616f5..1bcb57d 100644 --- a/Realtime/Internal/Controller/LCIMGoAwayController.cs +++ b/Realtime/Internal/Controller/LCIMGoAwayController.cs @@ -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 { diff --git a/Realtime/Internal/Controller/LCIMMessageController.cs b/Realtime/Internal/Controller/LCIMMessageController.cs index dad1565..784a895 100644 --- a/Realtime/Internal/Controller/LCIMMessageController.cs +++ b/Realtime/Internal/Controller/LCIMMessageController.cs @@ -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 { diff --git a/Realtime/Internal/Controller/LCIMSessionController.cs b/Realtime/Internal/Controller/LCIMSessionController.cs index c3767dc..28b913c 100644 --- a/Realtime/Internal/Controller/LCIMSessionController.cs +++ b/Realtime/Internal/Controller/LCIMSessionController.cs @@ -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 { diff --git a/Realtime/LCApplicationRealtimeExt.cs b/Realtime/LCApplicationRealtimeExt.cs deleted file mode 100644 index e26d47e..0000000 --- a/Realtime/LCApplicationRealtimeExt.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Threading.Tasks; -using LeanCloud.Realtime; -using LeanCloud.Realtime.Internal; - -namespace LeanCloud { - public static class LCApplicationRealtimeExt { - - } -} diff --git a/Realtime/LCIMClient.cs b/Realtime/LCIMClient.cs index 978229b..4799c4a 100644 --- a/Realtime/LCIMClient.cs +++ b/Realtime/LCIMClient.cs @@ -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; diff --git a/Realtime/LCIMOperationFailure.cs b/Realtime/LCIMOperationFailure.cs deleted file mode 100644 index 68e7e19..0000000 --- a/Realtime/LCIMOperationFailure.cs +++ /dev/null @@ -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 MemberList { - get; set; - } - - public LCIMOperationFailure(ErrorCommand error) { - Code = error.Code; - Reason = error.Reason; - MemberList = error.Pids.ToList(); - } - } -} diff --git a/Realtime/Realtime.csproj b/Realtime/Realtime.csproj index 0a710df..e9eaffd 100644 --- a/Realtime/Realtime.csproj +++ b/Realtime/Realtime.csproj @@ -23,5 +23,7 @@ + + diff --git a/Realtime/Result/LCIMOperationFailure.cs b/Realtime/Result/LCIMOperationFailure.cs new file mode 100644 index 0000000..73780e1 --- /dev/null +++ b/Realtime/Result/LCIMOperationFailure.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; + +namespace LeanCloud.Realtime { + /// + /// 操作失败 + /// + public class LCIMOperationFailure { + /// + /// 失败码 + /// + public int Code { + get; set; + } + + /// + /// 失败原因 + /// + public string Reason { + get; set; + } + + /// + /// 失败数据 + /// + public List IdList { + get; set; + } + + //public LCIMOperationFailure(ErrorCommand error) { + // Code = error.Code; + // Reason = error.Reason; + // MemberList = error.Pids.ToList(); + //} + } +} diff --git a/Realtime/LCIMPageResult.cs b/Realtime/Result/LCIMPageResult.cs similarity index 55% rename from Realtime/LCIMPageResult.cs rename to Realtime/Result/LCIMPageResult.cs index a559db6..c0879b5 100644 --- a/Realtime/LCIMPageResult.cs +++ b/Realtime/Result/LCIMPageResult.cs @@ -1,11 +1,20 @@ using System.Collections.ObjectModel; namespace LeanCloud.Realtime { + /// + /// 查询分页结果 + /// public class LCIMPageResult { + /// + /// 当前分页数据集 + /// public ReadOnlyCollection Results { get; internal set; } + /// + /// 下次请求的数据 + /// public string Next { get; internal set; } diff --git a/Realtime/LCIMPartiallySuccessResult.cs b/Realtime/Result/LCIMPartiallySuccessResult.cs similarity index 63% rename from Realtime/LCIMPartiallySuccessResult.cs rename to Realtime/Result/LCIMPartiallySuccessResult.cs index d9e8247..e91f336 100644 --- a/Realtime/LCIMPartiallySuccessResult.cs +++ b/Realtime/Result/LCIMPartiallySuccessResult.cs @@ -1,13 +1,20 @@ -using System; -using System.Collections.Generic; -using LeanCloud.Storage; +using System.Collections.Generic; namespace LeanCloud.Realtime { + /// + /// 部分成功结果 + /// public class LCIMPartiallySuccessResult { + /// + /// 成功数据集 + /// public List SuccessfulClientIdList { get; internal set; } + /// + /// 失败原因 + /// public List FailureList { get; internal set; } diff --git a/Realtime/Signature/ILCIMSignatureFactory.cs b/Realtime/Signature/ILCIMSignatureFactory.cs index 7b62de6..4690302 100644 --- a/Realtime/Signature/ILCIMSignatureFactory.cs +++ b/Realtime/Signature/ILCIMSignatureFactory.cs @@ -2,6 +2,9 @@ using System.Threading.Tasks; namespace LeanCloud.Realtime { + /// + /// 签名工程接口 + /// public interface ILCIMSignatureFactory { /// /// 登录签名 diff --git a/Realtime/protobuf/compile-client-proto.sh b/Realtime/protobuf/compile-client-proto.sh index d917889..c19f774 100644 --- a/Realtime/protobuf/compile-client-proto.sh +++ b/Realtime/protobuf/compile-client-proto.sh @@ -1 +1 @@ -protoc --proto_path=. --csharp_out=. messages2.proto.orig \ No newline at end of file +protoc --proto_path=. --csharp_out=../Internal/Protocol messages2.proto.orig \ No newline at end of file diff --git a/Realtime/protobuf/messages2.proto.orig b/Realtime/protobuf/messages2.proto.orig index 93a2156..2786f55 100644 --- a/Realtime/protobuf/messages2.proto.orig +++ b/Realtime/protobuf/messages2.proto.orig @@ -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 diff --git a/Test/Realtime.Test/Message.cs b/Test/Realtime.Test/Message.cs index 39dc034..cdebaaf 100644 --- a/Test/Realtime.Test/Message.cs +++ b/Test/Realtime.Test/Message.cs @@ -2,7 +2,6 @@ using System; using System.Collections.ObjectModel; using System.Threading.Tasks; -using System.Collections.Generic; using LeanCloud; using LeanCloud.Common; using LeanCloud.Storage; @@ -172,10 +171,9 @@ namespace Realtime.Test { string clientId = Guid.NewGuid().ToString(); LCIMClient client = new LCIMClient(clientId); LCIMConversation conversation = await m1.CreateConversation(new string[] { clientId }); - + await client.Open(); LCIMTextMessage textMessage = new LCIMTextMessage("hello"); await conversation.Send(textMessage); - client.OnUnreadMessagesCountUpdated = (convs) => { foreach (LCIMConversation conv in convs) { WriteLine($"unread count: {conv.Unread}"); @@ -183,21 +181,11 @@ namespace Realtime.Test { Assert.True(conv.LastMessage is LCIMTextMessage); LCIMTextMessage textMsg = conv.LastMessage as LCIMTextMessage; Assert.AreEqual(textMsg.Text, "hello"); + tcs.SetResult(true); } }; await client.Open(); - client.OnMessage = (conv, msg) => { - WriteLine($"unread count: {conv.Unread}"); - Assert.AreEqual(conv.Unread, 2); - Assert.True(conv.LastMessage is LCIMTextMessage); - LCIMTextMessage textMsg = conv.LastMessage as LCIMTextMessage; - Assert.AreEqual(textMsg.Text, "world"); - tcs.SetResult(true); - }; - textMessage = new LCIMTextMessage("world"); - await conversation.Send(textMessage); - await tcs.Task; } @@ -242,41 +230,5 @@ namespace Realtime.Test { await tcs.Task; } - - [Test] - [Order(8)] - public async Task MentionList() { - TaskCompletionSource tcs = new TaskCompletionSource(); - m2.OnMessage = (conv, msg) => { - Assert.True(msg.Mentioned); - Assert.True(msg.MentionIdList.Contains(m2.Id)); - tcs.SetResult(null); - }; - - LCIMTextMessage textMessage = new LCIMTextMessage("hello") { - MentionIdList = new List { m2.Id } - }; - await conversation.Send(textMessage); - - await tcs.Task; - } - - [Test] - [Order(9)] - public async Task MentionAll() { - TaskCompletionSource tcs = new TaskCompletionSource(); - m2.OnMessage = (conv, msg) => { - Assert.True(msg.Mentioned); - Assert.True(msg.MentionAll); - tcs.SetResult(null); - }; - - LCIMTextMessage textMessage = new LCIMTextMessage("world") { - MentionAll = true - }; - await conversation.Send(textMessage); - - await tcs.Task; - } } }