From ea099414393b91ceb5f3d6ec285a7a118e89d2e7 Mon Sep 17 00:00:00 2001 From: oneRain Date: Thu, 30 Apr 2020 13:35:34 +0800 Subject: [PATCH] * csharp-sdk.sln: * Program.cs: * RealtimeApp.csproj: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * SingleThreadSynchronizationContext.cs: chore: rtm 测试 app --- Test/RealtimeApp/Program.cs | 30 +++++++++++++++++++ Test/RealtimeApp/RealtimeApp.csproj | 5 ++++ .../SingleThreadSynchronizationContext.cs | 2 +- csharp-sdk.sln | 7 +++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Test/RealtimeApp/Program.cs b/Test/RealtimeApp/Program.cs index cdf0fcd..01ef348 100644 --- a/Test/RealtimeApp/Program.cs +++ b/Test/RealtimeApp/Program.cs @@ -1,9 +1,39 @@ using System; +using LeanCloud; +using LeanCloud.Realtime; + +using static System.Console; namespace RealtimeApp { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); + + SingleThreadSynchronizationContext.Run(async () => { + LCLogger.LogDelegate += Print; + LCApplication.Initialize("ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz", "NUKmuRbdAhg1vrb2wexYo1jo", "https://ikggdre2.lc-cn-n1-shared.com"); + + LCIMClient client = new LCIMClient("lean"); + await client.Open(); + //await client.Close(); + }); + } + + static void Print(LCLogLevel level, string info) { + switch (level) { + case LCLogLevel.Debug: + WriteLine($"[DEBUG] {DateTime.Now} {info}\n"); + break; + case LCLogLevel.Warn: + WriteLine($"[WARNING] {DateTime.Now} {info}\n"); + break; + case LCLogLevel.Error: + WriteLine($"[ERROR] {DateTime.Now} {info}\n"); + break; + default: + WriteLine(info); + break; + } } } } diff --git a/Test/RealtimeApp/RealtimeApp.csproj b/Test/RealtimeApp/RealtimeApp.csproj index 958d2f1..075081d 100644 --- a/Test/RealtimeApp/RealtimeApp.csproj +++ b/Test/RealtimeApp/RealtimeApp.csproj @@ -5,4 +5,9 @@ netcoreapp3.0 + + + + + diff --git a/Test/RealtimeApp/SingleThreadSynchronizationContext.cs b/Test/RealtimeApp/SingleThreadSynchronizationContext.cs index cd08e62..fdfb2c9 100644 --- a/Test/RealtimeApp/SingleThreadSynchronizationContext.cs +++ b/Test/RealtimeApp/SingleThreadSynchronizationContext.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using System.Collections.Concurrent; using System.Collections.Generic; -namespace LeanCloud.Common { +namespace RealtimeApp { /// /// 单线程环境,用于控制台应用 await 返回 /// diff --git a/csharp-sdk.sln b/csharp-sdk.sln index e1291ca..166d2e2 100644 --- a/csharp-sdk.sln +++ b/csharp-sdk.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Realtime", "Realtime\Realti EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Realtime.Test", "Test\Realtime.Test\Realtime.Test.csproj", "{746B0DE6-C504-4568-BA6D-4A08A91A5E35}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealtimeApp", "Test\RealtimeApp\RealtimeApp.csproj", "{4CB5E8C3-B1FC-45C3-B882-A9A43DFC6B1C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,10 +41,15 @@ Global {746B0DE6-C504-4568-BA6D-4A08A91A5E35}.Debug|Any CPU.Build.0 = Debug|Any CPU {746B0DE6-C504-4568-BA6D-4A08A91A5E35}.Release|Any CPU.ActiveCfg = Release|Any CPU {746B0DE6-C504-4568-BA6D-4A08A91A5E35}.Release|Any CPU.Build.0 = Release|Any CPU + {4CB5E8C3-B1FC-45C3-B882-A9A43DFC6B1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4CB5E8C3-B1FC-45C3-B882-A9A43DFC6B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4CB5E8C3-B1FC-45C3-B882-A9A43DFC6B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4CB5E8C3-B1FC-45C3-B882-A9A43DFC6B1C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {531F8181-FFE0-476E-9D0A-93F13CAD1183} = {C827DA2F-6AB4-48D8-AB5B-6DAB925F8933} {746B0DE6-C504-4568-BA6D-4A08A91A5E35} = {C827DA2F-6AB4-48D8-AB5B-6DAB925F8933} + {4CB5E8C3-B1FC-45C3-B882-A9A43DFC6B1C} = {C827DA2F-6AB4-48D8-AB5B-6DAB925F8933} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution version = 0.1.0