diff --git a/README.md b/README.md index 1015726..2df8106 100644 --- a/README.md +++ b/README.md @@ -63,21 +63,21 @@ | Package Name | Version | Downloads | | --------------------- | -------------------------------------------------- | --------------------------------------------------- | -| Install-Package JT808.DotNetty.Abstractions | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Abstractions.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Abstractions.svg) | -| Install-Package JT808.DotNetty.Core | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Core.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Core.svg) | -| Install-Package JT808.DotNetty.Tcp | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Tcp.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Tcp.svg) | -| Install-Package JT808.DotNetty.Udp | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Udp.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Udp.svg) | -| Install-Package JT808.DotNetty.WebApi | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.WebApi.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.WebApi.svg) | -| Install-Package JT808.DotNetty.WebApiClientTool | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.WebApiClientTool.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.WebApiClientTool.svg) | -| Install-Package JT808.DotNetty.Client | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Client.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Client.svg) | -| Install-Package JT808.DotNetty.Transmit | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Transmit.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Transmit.svg) | -| Install-Package JT808.DotNetty.Traffic | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Traffic.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Traffic.svg)| -| Install-Package JT808.DotNetty.SessionNotice | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.SessionNotice.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.SessionNotice.svg)| -| Install-Package JT808.DotNetty.ReplyMessage | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.ReplyMessage.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.ReplyMessage.svg)| -| Install-Package JT808.DotNetty.MsgLogging | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.MsgLogging.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.MsgLogging.svg)| -| Install-Package JT808.DotNetty.MsgIdHandler | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.MsgIdHandler.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.MsgIdHandler.svg)| -| Install-Package JT808.DotNetty.Kafka | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.Kafka.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.Kafka.svg) | -| Install-Package JT808.DotNetty.RabbitMQ | ![JT808](https://img.shields.io/nuget/v/JT808.DotNetty.RabbitMQ.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.DotNetty.RabbitMQ.svg) | +| Install-Package JT808.DotNetty.Abstractions | ![JT808.DotNetty.Abstractions](https://img.shields.io/nuget/v/JT808.DotNetty.Abstractions.svg) | ![JT808.DotNetty.Abstractions](https://img.shields.io/nuget/dt/JT808.DotNetty.Abstractions.svg) | +| Install-Package JT808.DotNetty.Core | ![JT808.DotNetty.Core](https://img.shields.io/nuget/v/JT808.DotNetty.Core.svg) | ![JT808.DotNetty.Core](https://img.shields.io/nuget/dt/JT808.DotNetty.Core.svg) | +| Install-Package JT808.DotNetty.Tcp | ![JT808.DotNetty.Tcp](https://img.shields.io/nuget/v/JT808.DotNetty.Tcp.svg) | ![JT808.DotNetty.Tcp](https://img.shields.io/nuget/dt/JT808.DotNetty.Tcp.svg) | +| Install-Package JT808.DotNetty.Udp | ![JT808.DotNetty.Udp](https://img.shields.io/nuget/v/JT808.DotNetty.Udp.svg) | ![JT808.DotNetty.Udp](https://img.shields.io/nuget/dt/JT808.DotNetty.Udp.svg) | +| Install-Package JT808.DotNetty.WebApi | ![JT808.DotNetty.WebApi](https://img.shields.io/nuget/v/JT808.DotNetty.WebApi.svg) | ![JT808.DotNetty.WebApi](https://img.shields.io/nuget/dt/JT808.DotNetty.WebApi.svg) | +| Install-Package JT808.DotNetty.WebApiClientTool | ![JT808.DotNetty.WebApiClientTool](https://img.shields.io/nuget/v/JT808.DotNetty.WebApiClientTool.svg) | ![JT808.DotNetty.WebApiClientTool](https://img.shields.io/nuget/dt/JT808.DotNetty.WebApiClientTool.svg) | +| Install-Package JT808.DotNetty.Client | ![JT808.DotNetty.Client](https://img.shields.io/nuget/v/JT808.DotNetty.Client.svg) | ![JT808.DotNetty.Client](https://img.shields.io/nuget/dt/JT808.DotNetty.Client.svg) | +| Install-Package JT808.DotNetty.Transmit | ![JT808.DotNetty.Transmit](https://img.shields.io/nuget/v/JT808.DotNetty.Transmit.svg) | ![JT808.DotNetty.Transmit](https://img.shields.io/nuget/dt/JT808.DotNetty.Transmit.svg) | +| Install-Package JT808.DotNetty.Traffic | ![JT808.DotNetty.Traffic](https://img.shields.io/nuget/v/JT808.DotNetty.Traffic.svg) | ![JT808.DotNetty.Traffic](https://img.shields.io/nuget/dt/JT808.DotNetty.Traffic.svg)| +| Install-Package JT808.DotNetty.SessionNotice | ![JT808.DotNetty.SessionNotice](https://img.shields.io/nuget/v/JT808.DotNetty.SessionNotice.svg) | ![JT808.DotNetty.SessionNotice](https://img.shields.io/nuget/dt/JT808.DotNetty.SessionNotice.svg)| +| Install-Package JT808.DotNetty.ReplyMessage | ![JT808.DotNetty.ReplyMessage](https://img.shields.io/nuget/v/JT808.DotNetty.ReplyMessage.svg) | ![JT808.DotNetty.ReplyMessage](https://img.shields.io/nuget/dt/JT808.DotNetty.ReplyMessage.svg)| +| Install-Package JT808.DotNetty.MsgLogging | ![JT808.DotNetty.MsgLogging](https://img.shields.io/nuget/v/JT808.DotNetty.MsgLogging.svg) | ![JT808.DotNetty.MsgLogging](https://img.shields.io/nuget/dt/JT808.DotNetty.MsgLogging.svg)| +| Install-Package JT808.DotNetty.MsgIdHandler | ![JT808.DotNetty.MsgIdHandler](https://img.shields.io/nuget/v/JT808.DotNetty.MsgIdHandler.svg) | ![JT808.DotNetty.MsgIdHandler](https://img.shields.io/nuget/dt/JT808.DotNetty.MsgIdHandler.svg)| +| Install-Package JT808.DotNetty.Kafka | ![JT808.DotNetty.Kafka](https://img.shields.io/nuget/v/JT808.DotNetty.Kafka.svg) | ![JT808.DotNetty.Kafka](https://img.shields.io/nuget/dt/JT808.DotNetty.Kafka.svg) | +| Install-Package JT808.DotNetty.RabbitMQ | ![JT808.DotNetty.RabbitMQ](https://img.shields.io/nuget/v/JT808.DotNetty.RabbitMQ.svg) | ![JT808.DotNetty.RabbitMQ](https://img.shields.io/nuget/dt/JT808.DotNetty.RabbitMQ.svg) | ## 基于core 3.1 Pipeline的NuGet安装 @@ -97,10 +97,9 @@ ## 举个栗子 - ### Pipeline -1.打开/simples/JT808.DotNetty.Simples.sln项目进行还原编译生成 +1.打开/simples/JT808.Simples.sln项目进行还原编译生成 2.进入JT808.Gateway.SimpleServer项目下的Debug目录运行服务端 @@ -111,7 +110,7 @@ ### DotNetty -1.打开/simples/JT808.DotNetty.Simples.sln项目进行还原编译生成 +1.打开/simples/JT808.Simples.sln项目进行还原编译生成 2.进入JT808.DotNetty.SimpleServer项目下的Debug目录运行服务端 diff --git a/simples/JT808.Gateway.SimpleClient/Program.cs b/simples/JT808.Gateway.SimpleClient/Program.cs index 499afdf..eba3ce6 100644 --- a/simples/JT808.Gateway.SimpleClient/Program.cs +++ b/simples/JT808.Gateway.SimpleClient/Program.cs @@ -26,10 +26,6 @@ namespace JT808.Gateway.SimpleClient { services.AddSingleton(); services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddLogging(options => { - options.AddConsole(); - options.SetMinimumLevel(LogLevel.Trace); - }); services.AddJT808Configure() .AddClient(); services.AddHostedService(); diff --git a/simples/JT808.Gateway.SimpleClient/Services/Up2019Service.cs b/simples/JT808.Gateway.SimpleClient/Services/Up2019Service.cs index 430f87a..1a8ba5e 100644 --- a/simples/JT808.Gateway.SimpleClient/Services/Up2019Service.cs +++ b/simples/JT808.Gateway.SimpleClient/Services/Up2019Service.cs @@ -24,7 +24,7 @@ namespace JT808.Gateway.SimpleClient.Services { string sim = "22222222222"; JT808TcpClient client1 = await jT808TcpClientFactory.Create(new JT808DeviceConfig(sim, "127.0.0.1", 808, JT808Version.JTT2019), cancellationToken); - Thread.Sleep(5000); + await Task.Delay(2000); //1.终端注册 await client1.SendAsync(JT808MsgId.终端注册.Create2019(sim, new JT808_0x0100() { @@ -43,7 +43,8 @@ namespace JT808.Gateway.SimpleClient.Services IMEI="123456", SoftwareVersion="v1.0.0" })); - await Task.Run(async () => { + _ = Task.Run(async() => + { while (!cancellationToken.IsCancellationRequested) { var i = 0; @@ -60,9 +61,9 @@ namespace JT808.Gateway.SimpleClient.Services StatusFlag = 10 })); i++; - Thread.Sleep(5000); + await Task.Delay(5000); } - },cancellationToken); + }, cancellationToken); } public Task StopAsync(CancellationToken cancellationToken) diff --git a/simples/JT808.Gateway.SimpleClient/Services/UpService.cs b/simples/JT808.Gateway.SimpleClient/Services/UpService.cs index a646f2a..4db9715 100644 --- a/simples/JT808.Gateway.SimpleClient/Services/UpService.cs +++ b/simples/JT808.Gateway.SimpleClient/Services/UpService.cs @@ -24,7 +24,7 @@ namespace JT808.Gateway.SimpleClient.Services { string sim = "11111111111"; JT808TcpClient client1 = await jT808TcpClientFactory.Create(new JT808DeviceConfig(sim, "127.0.0.1", 808), cancellationToken); - Thread.Sleep(5000); + await Task.Delay(2000); //1.终端注册 await client1.SendAsync(JT808MsgId.终端注册.Create(sim, new JT808_0x0100() { @@ -41,8 +41,8 @@ namespace JT808.Gateway.SimpleClient.Services { Code = "1234" })); - await Task.Run(async() => { - while (true) + _= Task.Run(async() => { + while (!cancellationToken.IsCancellationRequested) { var i = 0; //3.每5秒发一次 @@ -58,9 +58,9 @@ namespace JT808.Gateway.SimpleClient.Services StatusFlag = 10 })); i++; - Thread.Sleep(5000); + await Task.Delay(5000); } - }); + }, cancellationToken); } public Task StopAsync(CancellationToken cancellationToken) diff --git a/simples/JT808.DotNetty.Simples.sln b/simples/JT808.Simples.sln similarity index 96% rename from simples/JT808.DotNetty.Simples.sln rename to simples/JT808.Simples.sln index ec65682..1a12087 100644 --- a/simples/JT808.DotNetty.Simples.sln +++ b/simples/JT808.Simples.sln @@ -9,9 +9,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.DotNetty.SimpleClient EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.DotNetty.SimpleServer", "JT808.DotNetty.SimpleServer\JT808.DotNetty.SimpleServer.csproj", "{CCE6AEFB-1AB0-4BD9-8EA2-8B4CDD097E88}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT808.Gateway.SimpleServer", "JT808.Gateway.SimpleServer\JT808.Gateway.SimpleServer.csproj", "{98E1CDD0-4D4E-48FE-968E-260F0CD5F4D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SimpleServer", "JT808.Gateway.SimpleServer\JT808.Gateway.SimpleServer.csproj", "{98E1CDD0-4D4E-48FE-968E-260F0CD5F4D3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT808.Gateway.SimpleClient", "JT808.Gateway.SimpleClient\JT808.Gateway.SimpleClient.csproj", "{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SimpleClient", "JT808.Gateway.SimpleClient\JT808.Gateway.SimpleClient.csproj", "{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution