* LCIMClient.cs:
* Realtime.csproj: * LCIMPageResult.cs: * LCApplicationRealtimeExt.cs: * messages2.proto.orig: * LCIMOperationFailure.cs: * compile-client-proto.sh: * LCIMConversation.cs: * LCIMMessageSendOptions.cs: * LCHeartBeat.cs: * LCConnection.cs: * LCIMPartiallySuccessResult.cs: * LCIMController.cs: * LCIMGoAwayController.cs: * LCIMSessionController.cs: * LCIMMessageController.cs: * LCIMConversationController.cs: * ILCIMSignatureFactory.cs: chore: 整理命名空间和目录结构
parent
d404a1995c
commit
a95977e055
|
@ -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;
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using LeanCloud.Realtime;
|
||||
using LeanCloud.Realtime.Internal;
|
||||
|
||||
namespace LeanCloud {
|
||||
public static class LCApplicationRealtimeExt {
|
||||
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,5 +23,7 @@
|
|||
<Folder Include="Signature\" />
|
||||
<Folder Include="Internal\Controller\" />
|
||||
<Folder Include="Internal\Connection\" />
|
||||
<Folder Include="Internal\Protocol\" />
|
||||
<Folder Include="Result\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -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();
|
||||
//}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -2,6 +2,9 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 签名工程接口
|
||||
/// </summary>
|
||||
public interface ILCIMSignatureFactory {
|
||||
/// <summary>
|
||||
/// 登录签名
|
||||
|
|
|
@ -1 +1 @@
|
|||
protoc --proto_path=. --csharp_out=. messages2.proto.orig
|
||||
protoc --proto_path=. --csharp_out=../Internal/Protocol 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
|
||||
|
|
|
@ -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<object> tcs = new TaskCompletionSource<object>();
|
||||
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<string> { m2.Id }
|
||||
};
|
||||
await conversation.Send(textMessage);
|
||||
|
||||
await tcs.Task;
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Order(9)]
|
||||
public async Task MentionAll() {
|
||||
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue