diff --git a/README.md b/README.md index 5a01f96..78c4fa5 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,62 @@ ![design_model](https://github.com/SmallChi/JT808DotNetty/blob/master/doc/img/design_model.png) -## 集成功能实现 +## 基于Tcp的消息业务处理程序(JT808.DotNetty.Tcp) -### 1.集成原包分发器 +通过继承JT808.DotNetty.Core.Handlers.JT808MsgIdTcpHandlerBase去实现自定义的消息业务处理程序。 -### 2.集成WebApi服务器 +## 基于Udp的消息业务处理程序(JT808.DotNetty.Udp) -[WebApi接口服务](https://github.com/SmallChi/JT808DotNetty/blob/master/api/README.md) +通过继承JT808.DotNetty.Core.Handlers.JT808MsgIdUdpHandlerBase去实现自定义的消息业务处理程序。 -### 3.集成会话通知(在线/离线) +## 基于WebApi的消息业务处理程序(JT808.DotNetty.WebApi) -使用场景:有些超长待机的设备,不会实时保持连接,那么通过平台下发的命令是无法到达的,这时候就需要设备一上线,就即时通知服务去处理,然后在即时的下发消息到设备。 +通过继承JT808.DotNetty.Core.Handlers.JT808MsgIdHttpHandlerBase去实现自定义的WebApi接口服务。 + +[WebApi公共接口服务](https://github.com/SmallChi/JT808DotNetty/blob/master/api/README.md) + +## 集成接口功能(JT808.DotNetty.Abstractions) + +|接口名称|接口说明|使用场景| +|:------:|:------|:------| +| IJT808SessionPublishing| 会话通知(在线/离线)| 有些超长待机的设备,不会实时保持连接,那么通过平台下发的命令是无法到达的,这时候就需要设备一上线,就即时通知服务去处理,然后在即时的下发消息到设备。| +| IJT808SourcePackageDispatcher| 原包分发器| 需要将源数据转给其他平台| > 只要实现IJT808SessionPublishing接口的任意一款MQ都能实现该功能。 -### 4.集成业务消息处理程序 \ No newline at end of file +## 参考1 + +``` demo1 +static async Task Main(string[] args) +{ + var serverHostBuilder = new HostBuilder() + .ConfigureAppConfiguration((hostingContext, config) => + { + config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); + config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); + }) + .ConfigureLogging((context, logging) => + { + logging.AddConsole(); + logging.SetMinimumLevel(LogLevel.Trace); + }) + .ConfigureServices((hostContext, services) => + { + services.AddSingleton(); + services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)) + services.AddJT808Core(hostContext.Configuration) + .AddJT808TcpHost() + .AddJT808UdpHost() + .AddJT808WebApiHost(); + // 自定义Tcp消息处理业务 + services.Replace(new ServiceDescriptor(typeof(JT808MsgIdTcpHandlerBase), typeof(JT808MsgIdTcpCustomHandler), ServiceLifetime.Singleton)); + // 自定义Udp消息处理业务 + services.Replace(new ServiceDescriptor(typeof(JT808MsgIdUdpHandlerBase), typeof(JT808MsgIdUdpCustomHandler), ServiceLifetime.Singleton)); + }); + + await serverHostBuilder.RunConsoleAsync(); +} +``` + +如图所示: +![demo1](https://github.com/SmallChi/JT808DotNetty/blob/master/doc/img/demo1.png) \ No newline at end of file diff --git a/api/README.md b/api/README.md index f552e1c..90b9747 100644 --- a/api/README.md +++ b/api/README.md @@ -6,15 +6,27 @@ 默认端口:828 -## [统一下发设备消息服务](#send) +## 1.统一下发设备消息服务 -## [管理会话服务](#session) +[基于Tcp统一下发设备消息服务](#tcp_send) -## [原包分发器通道服务](#sourcepackage) +[基于Udp统一下发设备消息服务](#udp_send) -## [转发地址过滤服务](#transmit) +## 2.管理会话服务 -## [消息包计数服务](#counter) +[基于Tcp管理会话服务](#tcp_session) + +[基于Udp管理会话服务](#udp_session) + +## 3.转发地址过滤服务 + +[基于Tcp转发地址过滤服务](#tcp_transmit) + +## 4.消息包计数服务 + +[基于Tcp消息包计数服务](#tcp_counter) + +[基于Udp消息包计数服务](#udp_counter) ### 统一对象返回 JT808ResultDto\ @@ -33,9 +45,38 @@ | 404 | 没有该服务 | | 500 | 服务内部错误 | -### 统一下发设备消息接口 +### 基于Tcp统一下发设备消息服务 + +请求地址:UnificationTcpSend + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|------|:------:|:------| +| TerminalPhoneNo| string| 设备终端号| +| Data| byte[]| JT808 byte[]数组| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| bool| 是否成功| + +返回结果: + +``` result1 +{ + "Message":"", + "Code":200, + "Data":true +} +``` + +### 基于Udp统一下发设备消息服务 -请求地址:UnificationSend +请求地址:UnificationUdpSend 请求方式:POST @@ -62,13 +103,12 @@ } ``` -### 会话服务接口 +### 基于Tcp管理会话服务 -#### 统一会话信息对象返回 JT808SessionInfoDto +#### 统一会话信息对象返回 JT808TcpSessionInfoDto |属性|数据类型|参数说明| |------|------|------| -| ChannelId| string| 通道Id| | LastActiveTime| DateTime| 最后上线时间| | StartTime| DateTime| 上线时间| | TerminalPhoneNo|string| 终端手机号| @@ -76,7 +116,7 @@ #### 1.获取会话集合 -请求地址:Session/GetAll +请求地址:Session/Tcp/GetAll 请求方式:GET @@ -84,7 +124,7 @@ |属性|数据类型|参数说明| |:------:|:------:|:------| -| Data| List\ | 实际会话信息集合 | +| Data| List\ | 实际会话信息集合 | 返回结果: @@ -94,13 +134,11 @@ "Code":200, "Data":[ { - "ChannelId":"eadad23", "LastActiveTime":"2018-11-27 20:00:00", "StartTime":"2018-11-25 20:00:00", "TerminalPhoneNo":"123456789012", "RemoteAddressIP":"127.0.0.1:11808" },{ - "ChannelId":"eadad23", "LastActiveTime":"2018-11-27 20:00:00", "StartTime":"2018-11-25 20:00:00", "TerminalPhoneNo":"123456789013", @@ -112,7 +150,7 @@ #### 2.通过设备终端号移除对应会话 -请求地址:Session/RemoveByTerminalPhoneNo +请求地址:Session/Tcp/RemoveByTerminalPhoneNo 请求方式:POST @@ -138,11 +176,11 @@ } ``` -### 原包分发器通道服务 +### 基于Tcp转发地址过滤服务 -#### 1.添加原包转发地址 +#### 1.添加转发过滤地址 -请求地址:SourcePackage/Add +请求地址:Transmit/Add 请求方式:POST @@ -161,7 +199,7 @@ 返回结果: -``` sp1 +``` tr1 { "Message":"", "Code":200, @@ -169,77 +207,54 @@ } ``` -#### 2.删除原包转发地址(不能删除在网关服务器配置文件配的地址) +### 基于Udp管理会话服务 -请求地址:SourcePackage/Remove - -请求方式:POST - -请求参数: +#### 统一会话信息对象返回 JT808UdpSessionInfoDto |属性|数据类型|参数说明| -|:------:|:------:|:------| -| Host| string| ip地址| -| Port| int| 端口号| - -返回数据: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| Data| bool | 是否成功| - -返回结果: - -``` sp2 -{ - "Message":"", - "Code":200, - "Data":true -} -``` +|------|------|------| +| LastActiveTime| DateTime| 最后上线时间| +| StartTime| DateTime| 上线时间| +| TerminalPhoneNo|string| 终端手机号| +| RemoteAddressIP| string| 远程ip地址| -#### 3.获取原包信息集合 +#### 1.获取会话集合 -请求地址:SourcePackage/GetAll +请求地址:Session/Udp/GetAll 请求方式:GET 返回数据: |属性|数据类型|参数说明| -|------|:------:|:------| -| RemoteAddress| string | 远程ip地址| -| Registered| bool | 通道是否注册| -| Active| bool | 通道是否激活| -| Open| bool | 通道是否打开| +|:------:|:------:|:------| +| Data| List\ | 实际会话信息集合 | 返回结果: -``` sp3 +``` session1 { "Message":"", "Code":200, "Data":[ - { - "RemoteAddress":"127.0.0.1:6665", - "Registered":true, - "Active":true, - "Open":true + { + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789012", + "RemoteAddressIP":"127.0.0.1:11808" },{ - "RemoteAddress":"127.0.0.1:6667", - "Registered":true, - "Active":true, - "Open":true + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789013", + "RemoteAddressIP":"127.0.0.1:11808" } ] } ``` -### 转发地址过滤服务 - -#### 1.添加转发过滤地址 +#### 2.通过设备终端号移除对应会话 -请求地址:Transmit/Add +请求地址:Session/Udp/RemoveByTerminalPhoneNo 请求方式:POST @@ -247,8 +262,7 @@ |属性|数据类型|参数说明| |:------:|:------:|:------| -| Host| string| ip地址| -| Port| int| 端口号| +| terminalPhoneNo| string| 设备终端号| 返回数据: @@ -258,7 +272,7 @@ 返回结果: -``` tr1 +``` session3 { "Message":"", "Code":200, @@ -320,9 +334,9 @@ } ``` -### 计数服务接口 +### 基于Tcp消息包计数服务 -请求地址:GetAtomicCounter +请求地址:GetTcpAtomicCounter 请求方式:GET @@ -344,4 +358,30 @@ "MsgFailCount":0 } } +``` + +### 基于Udp消息包计数服务 + +请求地址:GetUdpAtomicCounter + +请求方式:GET + +返回数据: + +|属性|数据类型|参数说明| +|------|:------:|:------| +| MsgSuccessCount| long| 消息包成功数| +| MsgFailCount| long| 消息包失败数| + +返回结果: + +``` counter +{ + "Message":"", + "Code":200, + "Data":{ + "MsgSuccessCount":1000, + "MsgFailCount":0 + } +} ``` \ No newline at end of file diff --git a/doc/img/demo1.png b/doc/img/demo1.png new file mode 100644 index 0000000..da66b65 Binary files /dev/null and b/doc/img/demo1.png differ diff --git a/src/JT808.DotNetty.Core/Configurations/JT808Configuration.cs b/src/JT808.DotNetty.Core/Configurations/JT808Configuration.cs index 8b1b163..48f1975 100644 --- a/src/JT808.DotNetty.Core/Configurations/JT808Configuration.cs +++ b/src/JT808.DotNetty.Core/Configurations/JT808Configuration.cs @@ -34,11 +34,6 @@ namespace JT808.DotNetty.Core.Configurations /// public int WebApiPort { get; set; } = 828; - /// - /// 源包分发器配置 - /// - public List SourcePackageDispatcherClientConfigurations { get; set; } - /// /// 转发远程地址 (可选项)知道转发的地址有利于提升性能 /// 按照808的消息,有些请求必须要应答,但是转发可以不需要有应答可以节省部分资源包括: diff --git a/src/JT808.DotNetty.Core/JT808.DotNetty.Core.csproj b/src/JT808.DotNetty.Core/JT808.DotNetty.Core.csproj index 01d9fc8..7c52f0b 100644 --- a/src/JT808.DotNetty.Core/JT808.DotNetty.Core.csproj +++ b/src/JT808.DotNetty.Core/JT808.DotNetty.Core.csproj @@ -31,4 +31,10 @@ + + + C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.hosting.abstractions\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll + + + diff --git a/src/JT808.DotNetty.Core/JT808BackgroundService.cs b/src/JT808.DotNetty.Core/JT808BackgroundService.cs new file mode 100644 index 0000000..9c9e512 --- /dev/null +++ b/src/JT808.DotNetty.Core/JT808BackgroundService.cs @@ -0,0 +1,78 @@ +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace JT808.DotNetty.Core +{ + /// + /// + /// + /// + public abstract class JT808BackgroundService : IHostedService, IDisposable + { + /// + /// 默认次日过期 + /// + public virtual TimeSpan DelayTimeSpan + { + get + { + DateTime current = DateTime.Now; +#if DEBUG + DateTime tmp = current.AddSeconds(10); +#else + DateTime tmp = current.Date.AddDays(1).AddMilliseconds(-1); +#endif + return tmp.Subtract(current); + } + set { } + } + + private Task _executingTask; + + private readonly CancellationTokenSource _stoppingCts = new CancellationTokenSource(); + + protected abstract Task ExecuteAsync(CancellationToken stoppingToken); + + public void Dispose() + { + _stoppingCts.Cancel(); + } + + public virtual Task StartAsync(CancellationToken cancellationToken) + { + // Store the task we're executing + _executingTask = ExecuteAsync(_stoppingCts.Token); + // If the task is completed then return it, + // this will bubble cancellation and failure to the caller + if (_executingTask.IsCompleted) + { + return _executingTask; + } + // Otherwise it's running + return Task.CompletedTask; + } + + public virtual async Task StopAsync(CancellationToken cancellationToken) + { + // Stop called without start + if (_executingTask == null) + { + return; + } + try + { + // Signal cancellation to the executing method + _stoppingCts.Cancel(); + } + finally + { + // Wait until the task completes or the stop token triggers + await Task.WhenAny(_executingTask, Task.Delay(Timeout.Infinite,cancellationToken)); + } + } + } +} diff --git a/src/JT808.DotNetty.Core/Jobs/JT808TcpAtomicCouterResetDailyJob.cs b/src/JT808.DotNetty.Core/Jobs/JT808TcpAtomicCouterResetDailyJob.cs new file mode 100644 index 0000000..8894a01 --- /dev/null +++ b/src/JT808.DotNetty.Core/Jobs/JT808TcpAtomicCouterResetDailyJob.cs @@ -0,0 +1,35 @@ +using JT808.DotNetty.Core.Services; +using Microsoft.Extensions.Logging; +using System.Threading; +using System.Threading.Tasks; + +namespace JT808.DotNetty.Core.Jobs +{ + public class JT808TcpAtomicCouterResetDailyJob : JT808BackgroundService + { + private readonly ILogger _logger; + + private readonly JT808TcpAtomicCounterService _jT808TcpAtomicCounterService; + + public JT808TcpAtomicCouterResetDailyJob( + JT808TcpAtomicCounterService jT808TcpAtomicCounterService, + ILoggerFactory loggerFactory) + { + _jT808TcpAtomicCounterService = jT808TcpAtomicCounterService; + _logger =loggerFactory.CreateLogger(); + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + _logger.LogInformation($"{nameof(JT808TcpAtomicCouterResetDailyJob)} is starting."); + stoppingToken.Register(() => _logger.LogInformation($"{nameof(JT808TcpAtomicCouterResetDailyJob)} background task is stopping.")); + while (!stoppingToken.IsCancellationRequested) + { + _logger.LogInformation($"{nameof(JT808TcpAtomicCouterResetDailyJob)} task doing background work."); + _jT808TcpAtomicCounterService.Reset(); + await Task.Delay(DelayTimeSpan, stoppingToken); + } + _logger.LogInformation($"{nameof(JT808TcpAtomicCouterResetDailyJob)} background task is stopping."); + } + } +} diff --git a/src/JT808.DotNetty.Core/Jobs/JT808UdpAtomicCouterResetDailyJob.cs b/src/JT808.DotNetty.Core/Jobs/JT808UdpAtomicCouterResetDailyJob.cs new file mode 100644 index 0000000..973143d --- /dev/null +++ b/src/JT808.DotNetty.Core/Jobs/JT808UdpAtomicCouterResetDailyJob.cs @@ -0,0 +1,39 @@ +using JT808.DotNetty.Core.Services; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace JT808.DotNetty.Core.Jobs +{ + public class JT808UdpAtomicCouterResetDailyJob : JT808BackgroundService + { + private readonly ILogger _logger; + + private readonly JT808UdpAtomicCounterService _jT808UdpAtomicCounterService; + + public JT808UdpAtomicCouterResetDailyJob( + JT808UdpAtomicCounterService jT808UdpAtomicCounterService, + ILoggerFactory loggerFactory) + { + _jT808UdpAtomicCounterService = jT808UdpAtomicCounterService; + _logger =loggerFactory.CreateLogger(); + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + _logger.LogInformation($"{nameof(JT808UdpAtomicCouterResetDailyJob)} is starting."); + stoppingToken.Register(() => _logger.LogInformation($"{nameof(JT808UdpAtomicCouterResetDailyJob)} background task is stopping.")); + while (!stoppingToken.IsCancellationRequested) + { + _logger.LogInformation($"{nameof(JT808UdpAtomicCouterResetDailyJob)} task doing background work."); + _jT808UdpAtomicCounterService.Reset(); + await Task.Delay(DelayTimeSpan, stoppingToken); + } + _logger.LogInformation($"{nameof(JT808UdpAtomicCouterResetDailyJob)} background task is stopping."); + } + } +} diff --git a/src/JT808.DotNetty.Core/Metadata/JT808AtomicCounter.cs b/src/JT808.DotNetty.Core/Metadata/JT808AtomicCounter.cs index c0d68c5..72bc92a 100644 --- a/src/JT808.DotNetty.Core/Metadata/JT808AtomicCounter.cs +++ b/src/JT808.DotNetty.Core/Metadata/JT808AtomicCounter.cs @@ -18,6 +18,11 @@ namespace JT808.DotNetty.Core.Metadata this.counter = initialCount; } + public void Reset() + { + Interlocked.Exchange(ref counter, 0); + } + public long Increment() { return Interlocked.Increment(ref counter); diff --git a/src/JT808.DotNetty.Core/Services/JT808TcpAtomicCounterService.cs b/src/JT808.DotNetty.Core/Services/JT808TcpAtomicCounterService.cs index 069fb51..5c3fa0e 100644 --- a/src/JT808.DotNetty.Core/Services/JT808TcpAtomicCounterService.cs +++ b/src/JT808.DotNetty.Core/Services/JT808TcpAtomicCounterService.cs @@ -16,6 +16,12 @@ namespace JT808.DotNetty.Core.Services } + public void Reset() + { + MsgSuccessCounter.Reset(); + MsgFailCounter.Reset(); + } + public long MsgSuccessIncrement() { return MsgSuccessCounter.Increment(); diff --git a/src/JT808.DotNetty.Core/Services/JT808UdpAtomicCounterService.cs b/src/JT808.DotNetty.Core/Services/JT808UdpAtomicCounterService.cs index a5d0697..7c17fbf 100644 --- a/src/JT808.DotNetty.Core/Services/JT808UdpAtomicCounterService.cs +++ b/src/JT808.DotNetty.Core/Services/JT808UdpAtomicCounterService.cs @@ -16,6 +16,12 @@ namespace JT808.DotNetty.Core.Services } + public void Reset() + { + MsgSuccessCounter.Reset(); + MsgFailCounter.Reset(); + } + public long MsgSuccessIncrement() { return MsgSuccessCounter.Increment(); diff --git a/src/JT808.DotNetty.Hosting/Handlers/JT808MsgIdTcpCustomHandler.cs b/src/JT808.DotNetty.Hosting/Handlers/JT808MsgIdTcpCustomHandler.cs new file mode 100644 index 0000000..ba23262 --- /dev/null +++ b/src/JT808.DotNetty.Hosting/Handlers/JT808MsgIdTcpCustomHandler.cs @@ -0,0 +1,28 @@ +using JT808.DotNetty.Core; +using JT808.DotNetty.Core.Handlers; +using JT808.DotNetty.Core.Metadata; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.DotNetty.Hosting.Handlers +{ + public class JT808MsgIdTcpCustomHandler : JT808MsgIdTcpHandlerBase + { + public JT808MsgIdTcpCustomHandler( + ILoggerFactory loggerFactory, + JT808TcpSessionManager sessionManager) : base(sessionManager) + { + logger = loggerFactory.CreateLogger(); + } + + private readonly ILogger logger; + + public override JT808Response Msg0x0200(JT808Request request) + { + logger.LogDebug("Tcp_Msg0x0200"); + return base.Msg0x0200(request); + } + } +} diff --git a/src/JT808.DotNetty.Hosting/Handlers/JT808MsgIdUdpCustomHandler.cs b/src/JT808.DotNetty.Hosting/Handlers/JT808MsgIdUdpCustomHandler.cs new file mode 100644 index 0000000..d35eafc --- /dev/null +++ b/src/JT808.DotNetty.Hosting/Handlers/JT808MsgIdUdpCustomHandler.cs @@ -0,0 +1,28 @@ +using JT808.DotNetty.Core; +using JT808.DotNetty.Core.Handlers; +using JT808.DotNetty.Core.Metadata; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.DotNetty.Hosting.Handlers +{ + public class JT808MsgIdUdpCustomHandler : JT808MsgIdUdpHandlerBase + { + public JT808MsgIdUdpCustomHandler( + ILoggerFactory loggerFactory, + JT808UdpSessionManager sessionManager) : base(sessionManager) + { + logger = loggerFactory.CreateLogger(); + } + + private readonly ILogger logger; + + public override JT808Response Msg0x0200(JT808Request request) + { + logger.LogDebug("Udp_Msg0x0200"); + return base.Msg0x0200(request); + } + } +} diff --git a/src/JT808.DotNetty.Hosting/Program.cs b/src/JT808.DotNetty.Hosting/Program.cs index 57c4630..d92f966 100644 --- a/src/JT808.DotNetty.Hosting/Program.cs +++ b/src/JT808.DotNetty.Hosting/Program.cs @@ -1,4 +1,6 @@ using JT808.DotNetty.Core; +using JT808.DotNetty.Core.Handlers; +using JT808.DotNetty.Hosting.Handlers; using JT808.DotNetty.Tcp; using JT808.DotNetty.Udp; using JT808.DotNetty.WebApi; @@ -33,11 +35,15 @@ namespace JT808.DotNetty.Hosting .ConfigureServices((hostContext, services) => { services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); + services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); services.AddJT808Core(hostContext.Configuration) .AddJT808TcpHost() .AddJT808UdpHost() .AddJT808WebApiHost(); + // 自定义Tcp消息处理业务 + services.Replace(new ServiceDescriptor(typeof(JT808MsgIdTcpHandlerBase), typeof(JT808MsgIdTcpCustomHandler), ServiceLifetime.Singleton)); + // 自定义Udp消息处理业务 + services.Replace(new ServiceDescriptor(typeof(JT808MsgIdUdpHandlerBase), typeof(JT808MsgIdUdpCustomHandler), ServiceLifetime.Singleton)); }); await serverHostBuilder.RunConsoleAsync(); diff --git a/src/JT808.DotNetty.Tcp/JT808TcpDotnettyExtensions.cs b/src/JT808.DotNetty.Tcp/JT808TcpDotnettyExtensions.cs index db194ce..1db92cc 100644 --- a/src/JT808.DotNetty.Tcp/JT808TcpDotnettyExtensions.cs +++ b/src/JT808.DotNetty.Tcp/JT808TcpDotnettyExtensions.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json; using System; using System.Reflection; using System.Runtime.CompilerServices; +using JT808.DotNetty.Core.Jobs; [assembly: InternalsVisibleTo("JT808.DotNetty.Tcp.Test")] @@ -27,6 +28,7 @@ namespace JT808.DotNetty.Tcp serviceDescriptors.TryAddScoped(); serviceDescriptors.TryAddScoped(); serviceDescriptors.TryAddScoped(); + serviceDescriptors.AddHostedService(); serviceDescriptors.AddHostedService(); return serviceDescriptors; } diff --git a/src/JT808.DotNetty.Udp/JT808UdpDotnettyExtensions.cs b/src/JT808.DotNetty.Udp/JT808UdpDotnettyExtensions.cs index dbc16f4..7662744 100644 --- a/src/JT808.DotNetty.Udp/JT808UdpDotnettyExtensions.cs +++ b/src/JT808.DotNetty.Udp/JT808UdpDotnettyExtensions.cs @@ -1,6 +1,7 @@ using JT808.DotNetty.Core; using JT808.DotNetty.Core.Codecs; using JT808.DotNetty.Core.Handlers; +using JT808.DotNetty.Core.Jobs; using JT808.DotNetty.Core.Services; using JT808.DotNetty.Udp.Handlers; using Microsoft.Extensions.DependencyInjection; @@ -20,6 +21,7 @@ namespace JT808.DotNetty.Udp serviceDescriptors.TryAddSingleton(); serviceDescriptors.TryAddScoped(); serviceDescriptors.TryAddScoped(); + serviceDescriptors.AddHostedService(); serviceDescriptors.AddHostedService(); return serviceDescriptors; } diff --git a/src/JT808.Protocol b/src/JT808.Protocol index 5907058..641907a 160000 --- a/src/JT808.Protocol +++ b/src/JT808.Protocol @@ -1 +1 @@ -Subproject commit 59070584b9f74902431463ec770b9069429ac633 +Subproject commit 641907ad8373cf62d8973dedf76b84aaa894e52f