@@ -9,6 +9,7 @@ using JT809.DotNetty.Core.Handlers; | |||||
using JT809.DotNetty.Core.Interfaces; | using JT809.DotNetty.Core.Interfaces; | ||||
using JT809.DotNetty.Core.Metadata; | using JT809.DotNetty.Core.Metadata; | ||||
using JT809.Protocol; | using JT809.Protocol; | ||||
using JT809.Protocol.Configs; | |||||
using JT809.Protocol.Extensions; | using JT809.Protocol.Extensions; | ||||
using JT809.Protocol.MessageBody; | using JT809.Protocol.MessageBody; | ||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
@@ -42,11 +43,15 @@ namespace JT809.DotNetty.Core.Clients | |||||
private readonly IJT809ManualResetEvent manualResetEvent; | private readonly IJT809ManualResetEvent manualResetEvent; | ||||
private readonly JT809HeaderOptions JT809HeaderOptions; | |||||
public JT809MainClient( | public JT809MainClient( | ||||
JT809HeaderOptions jT809HeaderOptions, | |||||
IJT809ManualResetEvent jT809ManualResetEvent, | IJT809ManualResetEvent jT809ManualResetEvent, | ||||
IServiceProvider provider, | IServiceProvider provider, | ||||
ILoggerFactory loggerFactory) | ILoggerFactory loggerFactory) | ||||
{ | { | ||||
JT809HeaderOptions = jT809HeaderOptions; | |||||
this.serviceProvider = provider; | this.serviceProvider = provider; | ||||
this.logger = loggerFactory.CreateLogger<JT809MainClient>(); | this.logger = loggerFactory.CreateLogger<JT809MainClient>(); | ||||
this.manualResetEvent = jT809ManualResetEvent; | this.manualResetEvent = jT809ManualResetEvent; | ||||
@@ -102,7 +107,11 @@ namespace JT809.DotNetty.Core.Clients | |||||
//jT809_0X1001.UserId = userId; | //jT809_0X1001.UserId = userId; | ||||
//jT809_0X1001.Password = password; | //jT809_0X1001.Password = password; | ||||
var package = JT809.Protocol.Enums.JT809BusinessType.主链路登录请求消息.Create(_jT809_0x1001); | var package = JT809.Protocol.Enums.JT809BusinessType.主链路登录请求消息.Create(_jT809_0x1001); | ||||
await channel.WriteAndFlushAsync(new JT809Response(package, 100)); | |||||
package.Header.MsgGNSSCENTERID = JT809HeaderOptions.MsgGNSSCENTERID; | |||||
package.Header.Version = JT809HeaderOptions.Version; | |||||
package.Header.EncryptKey = JT809HeaderOptions.EncryptKey; | |||||
package.Header.EncryptFlag = JT809HeaderOptions.EncryptFlag; | |||||
await channel.WriteAndFlushAsync(new JT809Response(package, 1024)); | |||||
logger.LogInformation("等待登录应答结果..."); | logger.LogInformation("等待登录应答结果..."); | ||||
manualResetEvent.Pause(); | manualResetEvent.Pause(); | ||||
} | } | ||||
@@ -78,7 +78,7 @@ namespace JT809.DotNetty.Core.Handlers | |||||
logger.LogInformation($"{idleStateEvent.State.ToString()}>>>Heartbeat-{channelId}"); | logger.LogInformation($"{idleStateEvent.State.ToString()}>>>Heartbeat-{channelId}"); | ||||
//发送主链路保持请求数据包 | //发送主链路保持请求数据包 | ||||
var package = JT809BusinessType.主链路连接保持请求消息.Create(); | var package = JT809BusinessType.主链路连接保持请求消息.Create(); | ||||
JT809Response jT809Response = new JT809Response(package, 100); | |||||
JT809Response jT809Response = new JT809Response(package, 1024); | |||||
context.WriteAndFlushAsync(jT809Response); | context.WriteAndFlushAsync(jT809Response); | ||||
} | } | ||||
} | } | ||||
@@ -110,7 +110,7 @@ namespace JT809.DotNetty.Core.Handlers | |||||
string channelId = context.Channel.Id.AsShortText(); | string channelId = context.Channel.Id.AsShortText(); | ||||
//发送从链路保持请求数据包 | //发送从链路保持请求数据包 | ||||
var package = JT809BusinessType.从链路连接保持请求消息.Create(); | var package = JT809BusinessType.从链路连接保持请求消息.Create(); | ||||
JT809Response jT809Response = new JT809Response(package, 100); | |||||
JT809Response jT809Response = new JT809Response(package, 1024); | |||||
if (logger.IsEnabled(LogLevel.Information)) | if (logger.IsEnabled(LogLevel.Information)) | ||||
logger.LogInformation($"{idleStateEvent.State.ToString()}>>>Heartbeat-{channelId}-{JT809Serializer.Serialize(package, 100).ToHexString()}"); | logger.LogInformation($"{idleStateEvent.State.ToString()}>>>Heartbeat-{channelId}-{JT809Serializer.Serialize(package, 100).ToHexString()}"); | ||||
context.WriteAndFlushAsync(jT809Response); | context.WriteAndFlushAsync(jT809Response); | ||||
@@ -40,7 +40,7 @@ namespace JT809.DotNetty.Core.Handlers | |||||
{JT809BusinessType.主链路断开通知消息.ToUInt16Value(),Msg0x1007 }, | {JT809BusinessType.主链路断开通知消息.ToUInt16Value(),Msg0x1007 }, | ||||
{JT809BusinessType.主链路车辆动态信息交换业务.ToUInt16Value(), Msg0x1200}, | {JT809BusinessType.主链路车辆动态信息交换业务.ToUInt16Value(), Msg0x1200}, | ||||
{JT809BusinessType.下级平台主动关闭主从链路通知消息.ToUInt16Value(), Msg0x1008}, | {JT809BusinessType.下级平台主动关闭主从链路通知消息.ToUInt16Value(), Msg0x1008}, | ||||
{JT809BusinessType.从链路连接保持应答消息.ToUInt16Value(), Msg0x9002}, | |||||
{JT809BusinessType.从链路连接应答信息.ToUInt16Value(), Msg0x9002}, | |||||
{JT809BusinessType.从链路注销应答消息.ToUInt16Value(), Msg0x9004}, | {JT809BusinessType.从链路注销应答消息.ToUInt16Value(), Msg0x9004}, | ||||
{JT809BusinessType.从链路连接保持应答消息.ToUInt16Value(), Msg0x9006}, | {JT809BusinessType.从链路连接保持应答消息.ToUInt16Value(), Msg0x9006}, | ||||
}; | }; | ||||
@@ -55,6 +55,10 @@ namespace JT809.DotNetty.Core.Internal | |||||
{ | { | ||||
ReasonCode = reasonCode | ReasonCode = reasonCode | ||||
}); | }); | ||||
package.Header.MsgGNSSCENTERID = msgGNSSCENTERID; | |||||
package.Header.Version = JT809HeaderOptions.Version; | |||||
package.Header.EncryptKey = JT809HeaderOptions.EncryptKey; | |||||
package.Header.EncryptFlag = JT809HeaderOptions.EncryptFlag; | |||||
JT809Response jT809Response = new JT809Response(package, 100); | JT809Response jT809Response = new JT809Response(package, 100); | ||||
if (logger.IsEnabled(LogLevel.Information)) | if (logger.IsEnabled(LogLevel.Information)) | ||||
logger.LogInformation($"从链路断开通知消息>>>{JT809Serializer.Serialize(package, 100).ToHexString()}"); | logger.LogInformation($"从链路断开通知消息>>>{JT809Serializer.Serialize(package, 100).ToHexString()}"); | ||||
@@ -20,6 +20,7 @@ using Microsoft.Extensions.Options; | |||||
using JT808.DotNetty.WebApi; | using JT808.DotNetty.WebApi; | ||||
using JT809.DotNetty.Core.Session; | using JT809.DotNetty.Core.Session; | ||||
using JT809.DotNetty.Core.Events; | using JT809.DotNetty.Core.Events; | ||||
using JT809.Protocol; | |||||
[assembly: InternalsVisibleTo("JT809.DotNetty.Core.Test")] | [assembly: InternalsVisibleTo("JT809.DotNetty.Core.Test")] | ||||
@@ -44,7 +45,7 @@ namespace JT809.DotNetty.Core | |||||
}); | }); | ||||
} | } | ||||
public static IServiceCollection AddJT809Core(this IServiceCollection serviceDescriptors,IConfiguration configuration, Newtonsoft.Json.JsonSerializerSettings settings = null) | |||||
public static IJT809Builder AddJT809Core(this IJT809Builder builder,IConfiguration configuration, Newtonsoft.Json.JsonSerializerSettings settings = null) | |||||
{ | { | ||||
if (settings != null) | if (settings != null) | ||||
{ | { | ||||
@@ -56,14 +57,14 @@ namespace JT809.DotNetty.Core | |||||
return settings; | return settings; | ||||
}); | }); | ||||
} | } | ||||
serviceDescriptors.Configure<JT809Configuration>(configuration.GetSection("JT809Configuration")); | |||||
serviceDescriptors.TryAddSingleton<JT809SimpleSystemCollectService>(); | |||||
builder.Services.Configure<JT809Configuration>(configuration.GetSection("JT809Configuration")); | |||||
builder.Services.TryAddSingleton<JT809SimpleSystemCollectService>(); | |||||
//JT809计数器服务工厂 | //JT809计数器服务工厂 | ||||
serviceDescriptors.TryAddSingleton<JT809AtomicCounterServiceFactory>(); | |||||
builder.Services.TryAddSingleton<JT809AtomicCounterServiceFactory>(); | |||||
//JT809编解码器 | //JT809编解码器 | ||||
serviceDescriptors.TryAddScoped<JT809Decoder>(); | |||||
serviceDescriptors.TryAddScoped<JT809Encoder>(); | |||||
return serviceDescriptors; | |||||
builder.Services.TryAddScoped<JT809Decoder>(); | |||||
builder.Services.TryAddScoped<JT809Encoder>(); | |||||
return builder; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -73,23 +74,23 @@ namespace JT809.DotNetty.Core | |||||
/// </summary> | /// </summary> | ||||
/// <param name="serviceDescriptors"></param> | /// <param name="serviceDescriptors"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IServiceCollection AddJT809InferiorPlatform(this IServiceCollection serviceDescriptors, Action<JT809InferiorPlatformOptions> options) | |||||
public static IJT809Builder AddJT809InferiorPlatform(this IJT809Builder builder, Action<JT809InferiorPlatformOptions> options) | |||||
{ | { | ||||
serviceDescriptors.Configure(options); | |||||
builder.Services.Configure(options); | |||||
//主从链路客户端和服务端连接处理器 | //主从链路客户端和服务端连接处理器 | ||||
serviceDescriptors.TryAddScoped<JT809MainClientConnectionHandler>(); | |||||
serviceDescriptors.TryAddScoped<JT809SubordinateServerConnectionHandler>(); | |||||
builder.Services.TryAddScoped<JT809MainClientConnectionHandler>(); | |||||
builder.Services.TryAddScoped<JT809SubordinateServerConnectionHandler>(); | |||||
//主链路服务端会话管理 | //主链路服务端会话管理 | ||||
//serviceDescriptors.TryAddSingleton<JT809MainSessionManager>(); | //serviceDescriptors.TryAddSingleton<JT809MainSessionManager>(); | ||||
//主从链路接收消息默认业务处理器 | //主从链路接收消息默认业务处理器 | ||||
serviceDescriptors.TryAddSingleton<JT809InferiorMsgIdReceiveHandlerBase, JT809InferiorMsgIdReceiveDefaultHandler>(); | |||||
builder.Services.TryAddSingleton<JT809InferiorMsgIdReceiveHandlerBase, JT809InferiorMsgIdReceiveDefaultHandler>(); | |||||
//主从链路消息接收处理器 | //主从链路消息接收处理器 | ||||
serviceDescriptors.TryAddScoped<JT809SubordinateServerHandler>(); | |||||
builder.Services.TryAddScoped<JT809SubordinateServerHandler>(); | |||||
//主链路客户端 | //主链路客户端 | ||||
//serviceDescriptors.TryAddSingleton<JT809MainClient>(); | //serviceDescriptors.TryAddSingleton<JT809MainClient>(); | ||||
//从链路服务端 | //从链路服务端 | ||||
serviceDescriptors.AddHostedService<JT809SubordinateServerHost>(); | |||||
return serviceDescriptors; | |||||
builder.Services.AddHostedService<JT809SubordinateServerHost>(); | |||||
return builder; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -99,18 +100,18 @@ namespace JT809.DotNetty.Core | |||||
/// </summary> | /// </summary> | ||||
/// <param name="serviceDescriptors"></param> | /// <param name="serviceDescriptors"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IServiceCollection AddJT809InferiorPlatformClient(this IServiceCollection serviceDescriptors) | |||||
public static IJT809Builder AddJT809InferiorPlatformClient(this IJT809Builder builder) | |||||
{ | { | ||||
serviceDescriptors.TryAddSingleton<IJT809ManualResetEvent, JT809InferoprManualResetEvent>(); | |||||
builder.Services.TryAddSingleton<IJT809ManualResetEvent, JT809InferoprManualResetEvent>(); | |||||
//主从链路客户端和服务端连接处理器 | //主从链路客户端和服务端连接处理器 | ||||
serviceDescriptors.TryAddScoped<JT809MainClientConnectionHandler>(); | |||||
builder.Services.TryAddScoped<JT809MainClientConnectionHandler>(); | |||||
//主从链路接收消息默认业务处理器 | //主从链路接收消息默认业务处理器 | ||||
serviceDescriptors.TryAddSingleton<JT809InferiorMsgIdReceiveHandlerBase, JT809InferiorMsgIdReceiveDefaultHandler>(); | |||||
builder.Services.TryAddSingleton<JT809InferiorMsgIdReceiveHandlerBase, JT809InferiorMsgIdReceiveDefaultHandler>(); | |||||
//主从链路消息接收处理器 | //主从链路消息接收处理器 | ||||
serviceDescriptors.TryAddScoped<JT809MainClientHandler>(); | |||||
builder.Services.TryAddScoped<JT809MainClientHandler>(); | |||||
//主链路客户端 | //主链路客户端 | ||||
serviceDescriptors.TryAddSingleton<JT809MainClient>(); | |||||
return serviceDescriptors; | |||||
builder.Services.TryAddSingleton<JT809MainClient>(); | |||||
return builder; | |||||
} | } | ||||
@@ -121,38 +122,38 @@ namespace JT809.DotNetty.Core | |||||
/// </summary> | /// </summary> | ||||
/// <param name="serviceDescriptors"></param> | /// <param name="serviceDescriptors"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IServiceCollection AddJT809SuperiorPlatform(this IServiceCollection serviceDescriptors, IConfiguration superiorPlatformConfiguration=null, Action<JT809SuperiorPlatformOptions> options=null) | |||||
public static IJT809Builder AddJT809SuperiorPlatform(this IJT809Builder builder, IConfiguration superiorPlatformConfiguration=null, Action<JT809SuperiorPlatformOptions> options=null) | |||||
{ | { | ||||
if (superiorPlatformConfiguration != null) | if (superiorPlatformConfiguration != null) | ||||
{ | { | ||||
serviceDescriptors.Configure<JT809SuperiorPlatformOptions>(superiorPlatformConfiguration.GetSection("JT809SuperiorPlatformConfiguration")); | |||||
builder.Services.Configure<JT809SuperiorPlatformOptions>(superiorPlatformConfiguration.GetSection("JT809SuperiorPlatformConfiguration")); | |||||
} | } | ||||
if (options != null) | if (options != null) | ||||
{ | { | ||||
serviceDescriptors.Configure(options); | |||||
builder.Services.Configure(options); | |||||
} | } | ||||
serviceDescriptors.TryAddSingleton<IJT809VerifyCodeGenerator, JT809VerifyCodeGeneratorDefaultImpl>(); | |||||
builder.Services.TryAddSingleton<IJT809VerifyCodeGenerator, JT809VerifyCodeGeneratorDefaultImpl>(); | |||||
//主从链路客户端和服务端连接处理器 | //主从链路客户端和服务端连接处理器 | ||||
serviceDescriptors.TryAddScoped<JT809MainServerConnectionHandler>(); | |||||
serviceDescriptors.TryAddScoped<JT809SubordinateClientConnectionHandler>(); | |||||
builder.Services.TryAddScoped<JT809MainServerConnectionHandler>(); | |||||
builder.Services.TryAddScoped<JT809SubordinateClientConnectionHandler>(); | |||||
//主链路服务端会话管理 | //主链路服务端会话管理 | ||||
serviceDescriptors.TryAddSingleton<JT809SuperiorMainSessionManager>(); | |||||
builder.Services.TryAddSingleton<JT809SuperiorMainSessionManager>(); | |||||
//主从链路接收消息默认业务处理器 | //主从链路接收消息默认业务处理器 | ||||
serviceDescriptors.TryAddSingleton<JT809SuperiorMsgIdReceiveHandlerBase, JT809SuperiorMsgIdReceiveDefaultHandler>(); | |||||
builder.Services.TryAddSingleton<JT809SuperiorMsgIdReceiveHandlerBase, JT809SuperiorMsgIdReceiveDefaultHandler>(); | |||||
//主从链路消息接收处理器 | //主从链路消息接收处理器 | ||||
serviceDescriptors.TryAddScoped<JT809MainServerHandler>(); | |||||
serviceDescriptors.TryAddScoped<JT809SubordinateClientHandler>(); | |||||
serviceDescriptors.TryAddSingleton<IJT809SubordinateLoginService, JT809SubordinateLoginImplService>(); | |||||
serviceDescriptors.TryAddSingleton<IJT809SubordinateLinkNotifyService, JT809SubordinateLinkNotifyImplService>(); | |||||
builder.Services.TryAddScoped<JT809MainServerHandler>(); | |||||
builder.Services.TryAddScoped<JT809SubordinateClientHandler>(); | |||||
builder.Services.TryAddSingleton<IJT809SubordinateLoginService, JT809SubordinateLoginImplService>(); | |||||
builder.Services.TryAddSingleton<IJT809SubordinateLinkNotifyService, JT809SubordinateLinkNotifyImplService>(); | |||||
//从链路客户端 | //从链路客户端 | ||||
serviceDescriptors.TryAddSingleton<JT809SubordinateClient>(); | |||||
builder.Services.TryAddSingleton<JT809SubordinateClient>(); | |||||
//主链路服务端 | //主链路服务端 | ||||
serviceDescriptors.AddHostedService<JT809MainServerHost>(); | |||||
builder.Services.AddHostedService<JT809MainServerHost>(); | |||||
//上级平台webapi | //上级平台webapi | ||||
serviceDescriptors.TryAddSingleton<JT809SuperiorWebAPIHandlerBase, JT809SuperiorWebAPIDefaultHandler>(); | |||||
serviceDescriptors.TryAddScoped<JT809SuperiorWebAPIServerHandler>(); | |||||
serviceDescriptors.AddHostedService<JT809MainWebAPIServerHost>(); | |||||
return serviceDescriptors; | |||||
builder.Services.TryAddSingleton<JT809SuperiorWebAPIHandlerBase, JT809SuperiorWebAPIDefaultHandler>(); | |||||
builder.Services.TryAddScoped<JT809SuperiorWebAPIServerHandler>(); | |||||
builder.Services.AddHostedService<JT809MainWebAPIServerHost>(); | |||||
return builder; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -12,6 +12,7 @@ using JT809.Protocol.SubMessageBody; | |||||
using JT809.Protocol.Metadata; | using JT809.Protocol.Metadata; | ||||
using JT809.Protocol.MessageBody; | using JT809.Protocol.MessageBody; | ||||
using JT809.Protocol.Enums; | using JT809.Protocol.Enums; | ||||
using JT809.Protocol.Configs; | |||||
namespace JT809.Inferior.Client | namespace JT809.Inferior.Client | ||||
{ | { | ||||
@@ -19,10 +20,13 @@ namespace JT809.Inferior.Client | |||||
{ | { | ||||
private readonly JT809MainClient mainClient; | private readonly JT809MainClient mainClient; | ||||
private readonly ILogger<JT809InferiorService> logger; | private readonly ILogger<JT809InferiorService> logger; | ||||
private readonly JT809HeaderOptions JT809HeaderOptions; | |||||
public JT809InferiorService( | public JT809InferiorService( | ||||
JT809HeaderOptions jT809HeaderOptions, | |||||
ILoggerFactory loggerFactory, | ILoggerFactory loggerFactory, | ||||
JT809MainClient mainClient) | JT809MainClient mainClient) | ||||
{ | { | ||||
JT809HeaderOptions = jT809HeaderOptions; | |||||
this.mainClient = mainClient; | this.mainClient = mainClient; | ||||
logger = loggerFactory.CreateLogger<JT809InferiorService>(); | logger = loggerFactory.CreateLogger<JT809InferiorService>(); | ||||
} | } | ||||
@@ -68,7 +72,11 @@ namespace JT809.Inferior.Client | |||||
} | } | ||||
}; | }; | ||||
var package = JT809.Protocol.Enums.JT809BusinessType.主链路车辆动态信息交换业务.Create(jT809_0X1200); | var package = JT809.Protocol.Enums.JT809BusinessType.主链路车辆动态信息交换业务.Create(jT809_0X1200); | ||||
mainClient.SendAsync(new JT809Response(package, 256)); | |||||
package.Header.MsgGNSSCENTERID = JT809HeaderOptions.MsgGNSSCENTERID; | |||||
package.Header.Version = JT809HeaderOptions.Version; | |||||
package.Header.EncryptKey = JT809HeaderOptions.EncryptKey; | |||||
package.Header.EncryptFlag = JT809HeaderOptions.EncryptFlag; | |||||
mainClient.SendAsync(new JT809Response(package, 1024)); | |||||
logger.LogDebug($"Thread:{Thread.CurrentThread.ManagedThreadId}-2s"); | logger.LogDebug($"Thread:{Thread.CurrentThread.ManagedThreadId}-2s"); | ||||
Thread.Sleep(2000); | Thread.Sleep(2000); | ||||
} | } | ||||
@@ -103,7 +111,11 @@ namespace JT809.Inferior.Client | |||||
} | } | ||||
}; | }; | ||||
var package = JT809BusinessType.主链路车辆动态信息交换业务.Create(jT809_0X1200); | var package = JT809BusinessType.主链路车辆动态信息交换业务.Create(jT809_0X1200); | ||||
mainClient.SendAsync(new JT809Response(package, 256)); | |||||
package.Header.MsgGNSSCENTERID = JT809HeaderOptions.MsgGNSSCENTERID; | |||||
package.Header.Version = JT809HeaderOptions.Version; | |||||
package.Header.EncryptKey = JT809HeaderOptions.EncryptKey; | |||||
package.Header.EncryptFlag = JT809HeaderOptions.EncryptFlag; | |||||
mainClient.SendAsync(new JT809Response(package, 1024)); | |||||
logger.LogDebug($"Thread:{Thread.CurrentThread.ManagedThreadId}-4s"); | logger.LogDebug($"Thread:{Thread.CurrentThread.ManagedThreadId}-4s"); | ||||
Thread.Sleep(4000); | Thread.Sleep(4000); | ||||
} | } | ||||
@@ -1,6 +1,7 @@ | |||||
using JT809.DotNetty.Core; | using JT809.DotNetty.Core; | ||||
using JT809.DotNetty.Core.Handlers; | using JT809.DotNetty.Core.Handlers; | ||||
using JT809.Protocol; | using JT809.Protocol; | ||||
using JT809.Protocol.Configs; | |||||
using Microsoft.Extensions.Configuration; | using Microsoft.Extensions.Configuration; | ||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using Microsoft.Extensions.DependencyInjection.Extensions; | using Microsoft.Extensions.DependencyInjection.Extensions; | ||||
@@ -30,8 +31,14 @@ namespace JT809.Inferior.Client | |||||
{ | { | ||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | services.AddSingleton<ILoggerFactory, LoggerFactory>(); | ||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | ||||
services.AddJT809Configure(); | |||||
services.AddJT809Core(hostContext.Configuration) | |||||
services.AddSingleton(new JT809HeaderOptions | |||||
{ | |||||
MsgGNSSCENTERID = 20141013, | |||||
Version = new JT809Header_Version(1, 0, 0), | |||||
EncryptKey = 9595 | |||||
}); | |||||
services.AddJT809Configure() | |||||
.AddJT809Core(hostContext.Configuration) | |||||
.AddJT809InferiorPlatformClient(); | .AddJT809InferiorPlatformClient(); | ||||
services.AddHostedService<JT809InferiorService>(); | services.AddHostedService<JT809InferiorService>(); | ||||
}); | }); | ||||
@@ -1,5 +1,7 @@ | |||||
using JT809.DotNetty.Core; | using JT809.DotNetty.Core; | ||||
using JT809.DotNetty.Core.Handlers; | using JT809.DotNetty.Core.Handlers; | ||||
using JT809.Protocol; | |||||
using JT809.Protocol.Configs; | |||||
using Microsoft.Extensions.Configuration; | using Microsoft.Extensions.Configuration; | ||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using Microsoft.Extensions.DependencyInjection.Extensions; | using Microsoft.Extensions.DependencyInjection.Extensions; | ||||
@@ -7,8 +9,6 @@ using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | using Microsoft.Extensions.Logging; | ||||
using System; | using System; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using JT809.Protocol.Extensions.DependencyInjection; | |||||
using JT809.Protocol.Extensions.DependencyInjection.Options; | |||||
namespace JT809.Inferior.Server | namespace JT809.Inferior.Server | ||||
{ | { | ||||
@@ -37,14 +37,14 @@ namespace JT809.Inferior.Server | |||||
{ | { | ||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | services.AddSingleton<ILoggerFactory, LoggerFactory>(); | ||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | ||||
services.AddJT809Configure(new JT809Options | |||||
services.AddSingleton(new JT809HeaderOptions | |||||
{ | { | ||||
HeaderOptions=new Protocol.Configs.JT809HeaderOptions | |||||
{ | |||||
MsgGNSSCENTERID=100210 | |||||
} | |||||
MsgGNSSCENTERID = 20141013, | |||||
Version = new JT809Header_Version(1, 0, 0), | |||||
EncryptKey = 9595 | |||||
}); | }); | ||||
services.AddJT809Core(hostContext.Configuration) | |||||
services.AddJT809Configure() | |||||
.AddJT809Core(hostContext.Configuration) | |||||
.AddJT809InferiorPlatform(options: options => { | .AddJT809InferiorPlatform(options: options => { | ||||
options.TcpPort = 809; | options.TcpPort = 809; | ||||
}); | }); | ||||
@@ -2,7 +2,7 @@ | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<OutputType>Exe</OutputType> | <OutputType>Exe</OutputType> | ||||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -11,6 +11,7 @@ using Microsoft.Extensions.Logging; | |||||
using System; | using System; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using JT809.KafkaService; | using JT809.KafkaService; | ||||
using JT809.Protocol; | |||||
namespace JT809.Superior.Server | namespace JT809.Superior.Server | ||||
{ | { | ||||
@@ -35,9 +36,16 @@ namespace JT809.Superior.Server | |||||
{ | { | ||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | services.AddSingleton<ILoggerFactory, LoggerFactory>(); | ||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | ||||
services.AddJT809Core(hostContext.Configuration) | |||||
services.AddSingleton(new JT809HeaderOptions | |||||
{ | |||||
MsgGNSSCENTERID = 20141013, | |||||
Version = new JT809Header_Version(1, 0, 0), | |||||
EncryptKey = 9595 | |||||
}); | |||||
services.AddJT809Configure() | |||||
.AddJT809Core(hostContext.Configuration) | |||||
.AddJT809SuperiorPlatform(options:options => { | .AddJT809SuperiorPlatform(options:options => { | ||||
options.TcpPort = 808; | |||||
options.TcpPort = 809; | |||||
}); | }); | ||||
services.Configure<JT809GpsOptions>(hostContext.Configuration.GetSection("JT809GpsOptions")); | services.Configure<JT809GpsOptions>(hostContext.Configuration.GetSection("JT809GpsOptions")); | ||||
services.AddJT809KafkaProducerService(hostContext.Configuration); | services.AddJT809KafkaProducerService(hostContext.Configuration); | ||||
@@ -15,7 +15,8 @@ | |||||
"JT809Configuration": { | "JT809Configuration": { | ||||
"SubordinateClientEnable": false | "SubordinateClientEnable": false | ||||
}, | }, | ||||
"KafkaProducerConfig": { | |||||
"JT809ProducerConfig": { | |||||
"TopicName": "jt809", | |||||
"BootstrapServers": "127.0.0.1:9092" | "BootstrapServers": "127.0.0.1:9092" | ||||
}, | }, | ||||
"JT809GpsOptions": { | "JT809GpsOptions": { | ||||
@@ -43,7 +43,8 @@ namespace JT809.DotNetty.Host.Test | |||||
Version = new JT809Header_Version(1, 0, 0), | Version = new JT809Header_Version(1, 0, 0), | ||||
EncryptKey = 9595 | EncryptKey = 9595 | ||||
}); | }); | ||||
services.AddJT809Core(hostContext.Configuration) | |||||
services.AddJT809Configure() | |||||
.AddJT809Core(hostContext.Configuration) | |||||
.AddJT809SuperiorPlatform(options:options=> { | .AddJT809SuperiorPlatform(options:options=> { | ||||
options.TcpPort = 839; | options.TcpPort = 839; | ||||
}); | }); | ||||