@@ -1,24 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj" /> | |||||
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,44 +0,0 @@ | |||||
using JT808.Gateway.BusinessServices.MsgIdHandler; | |||||
using JT808.Gateway.Configs.Kafka; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Gateway.PubSub; | |||||
using JT808.Protocol; | |||||
using JT808.Protocol.Extensions; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.MsgIdHandler.Test | |||||
{ | |||||
public class JT808DotNettyMsgIdHandlerDefaultImpl : IJT808MsgIdHandler | |||||
{ | |||||
public readonly ILogger<JT808DotNettyMsgIdHandlerDefaultImpl> logger; | |||||
public JT808DotNettyMsgIdHandlerDefaultImpl(ILoggerFactory loggerFactory, | |||||
IServiceProvider serviceProvider) { | |||||
logger = loggerFactory.CreateLogger<JT808DotNettyMsgIdHandlerDefaultImpl>(); | |||||
Task.Run(()=> { | |||||
while (true) | |||||
{ | |||||
Thread.Sleep(5000); | |||||
using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig | |||||
{ | |||||
BootstrapServers = "127.0.0.1:9092", | |||||
TopicName = "JT808Msg" | |||||
})) | |||||
{ | |||||
jT808MsgProducer.ProduceAsync("123456", new byte[] { 0x7E, 0, 0x7E }).Wait(); | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
public void Processor((string TerminalNo, byte[] Data) parameter) | |||||
{ | |||||
logger.LogDebug($"{parameter.TerminalNo}:{parameter.Data.ToHexString()}"); | |||||
} | |||||
} | |||||
} |
@@ -1,39 +0,0 @@ | |||||
using JT808.Gateway.BusinessServices.MsgIdHandler; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Protocol; | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.MsgIdHandler.Test | |||||
{ | |||||
class Program | |||||
{ | |||||
async static Task Main(string[] args) | |||||
{ | |||||
var serverHostBuilder = new HostBuilder() | |||||
.UseEnvironment(args[0].Split('=')[1]) | |||||
.ConfigureAppConfiguration((hostingContext,config) => { | |||||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |||||
.AddJsonFile($"appsettings.{ hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); | |||||
}) | |||||
.ConfigureLogging(configLogging => { | |||||
configLogging.AddConsole(); | |||||
configLogging.SetMinimumLevel(LogLevel.Trace); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => { | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddJT808Configure() | |||||
.AddJT808ClientKafka() | |||||
.AddMsgConsumer(hostContext.Configuration) | |||||
.AddJT808MsgIdHandler<JT808DotNettyMsgIdHandlerDefaultImpl>(); | |||||
}); | |||||
await serverHostBuilder.RunConsoleAsync(); | |||||
} | |||||
} | |||||
} |
@@ -1,25 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj" /> | |||||
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,52 +0,0 @@ | |||||
using JJT808.Gateway.Kafka; | |||||
using JT808.Gateway.BusinessServices.MsgLogging; | |||||
using JT808.Gateway.Configs.Kafka; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Gateway.PubSub; | |||||
using JT808.Protocol.Extensions; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.MsgLogging.Test | |||||
{ | |||||
public class JT808MsgLoggingImpl : IJT808MsgLogging | |||||
{ | |||||
public readonly ILogger<JT808MsgLoggingImpl> logger; | |||||
public JT808MsgLoggingImpl(ILoggerFactory loggerFactory) { | |||||
logger = loggerFactory.CreateLogger<JT808MsgLoggingImpl>(); | |||||
Task.Run(() => { | |||||
while (true) | |||||
{ | |||||
Thread.Sleep(5000); | |||||
using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig | |||||
{ | |||||
BootstrapServers = "127.0.0.1:9092", | |||||
TopicName = "JT808Msg" | |||||
})) | |||||
{ | |||||
jT808MsgProducer.ProduceAsync("123456", new byte[] { 0x7E, 0,0,0,0, 0x7E }).Wait(); | |||||
} | |||||
JT808MsgReplyProducerConfig JT808MsgProducerConfig = new JT808MsgReplyProducerConfig | |||||
{ | |||||
TopicName = "JT808MsgReply", | |||||
BootstrapServers = "127.0.0.1:9092", | |||||
}; | |||||
using (IJT808MsgReplyProducer jT808MsgProducer = new JT808MsgReplyProducer(JT808MsgProducerConfig)) | |||||
{ | |||||
jT808MsgProducer.ProduceAsync("123456", new byte[] { 0x7E,1,1,1,1, 0x7E }).Wait(); | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
public void Processor((string TerminalNo, byte[] Data) parameter, JT808MsgLoggingType jT808MsgLoggingType) | |||||
{ | |||||
logger.LogDebug($"{parameter.TerminalNo}:{parameter.Data.ToHexString()},方向:{jT808MsgLoggingType.ToString()}"); | |||||
} | |||||
} | |||||
} |
@@ -1,43 +0,0 @@ | |||||
using JT808.Gateway.BusinessServices.MsgLogging; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Protocol; | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using Microsoft.Extensions.Logging.Console; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.MsgLogging.Test | |||||
{ | |||||
class Program | |||||
{ | |||||
async static Task Main(string[] args) | |||||
{ | |||||
var hostBuilder = new HostBuilder() | |||||
.UseEnvironment(args[0].Split('=')[1]) | |||||
.ConfigureAppConfiguration((hostContext,config)=> { | |||||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |||||
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); | |||||
}) | |||||
.ConfigureLogging((hostContext, configLogging) => { | |||||
configLogging.AddConsole(); | |||||
configLogging.SetMinimumLevel(LogLevel.Trace); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => { | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddJT808Configure() | |||||
.AddJT808ClientKafka() | |||||
.AddMsgConsumer(hostContext.Configuration) | |||||
.AddMsgReplyConsumer(hostContext.Configuration) | |||||
.AddJT808MsgLogging<JT808MsgLoggingImpl>(); | |||||
}) | |||||
; | |||||
await hostBuilder.RunConsoleAsync(); | |||||
} | |||||
} | |||||
} |
@@ -1,25 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj" /> | |||||
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,48 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
using JT808.Gateway.BusinessServices.ReplyMessage; | |||||
using JT808.Gateway.Configs.Kafka; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Gateway.PubSub; | |||||
using JT808.Protocol; | |||||
using JT808.Protocol.Extensions; | |||||
using Microsoft.Extensions.Logging; | |||||
namespace JT808.Gateway.ReplyMessage.Test | |||||
{ | |||||
public class JT808DotNettyReplyMessageServiceInherited : JT808ReplyMessageService | |||||
{ | |||||
public readonly ILogger<JT808DotNettyReplyMessageServiceInherited> logger; | |||||
public JT808DotNettyReplyMessageServiceInherited(IJT808Config jT808Config, | |||||
IJT808MsgReplyProducer jT808MsgReplyProducer, | |||||
ILoggerFactory loggerFactory) | |||||
: base(jT808Config, jT808MsgReplyProducer) | |||||
{ | |||||
logger = loggerFactory.CreateLogger<JT808DotNettyReplyMessageServiceInherited>(); | |||||
Task.Run(() => { | |||||
while (true) | |||||
{ | |||||
Thread.Sleep(5000); | |||||
using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig | |||||
{ | |||||
BootstrapServers = "127.0.0.1:9092", | |||||
TopicName = "JT808Msg" | |||||
})) | |||||
{ | |||||
jT808MsgProducer.ProduceAsync("011111111111", "7E02000032011111111111012E00000000000C00000160E42506C30C82002C00000000180914142057010400001DC003020000250400000000300115310100977E".ToHexBytes()).Wait(); | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
public override void Processor((string TerminalNo, byte[] Data) parameter) | |||||
{ | |||||
logger.LogDebug($"{parameter.TerminalNo}:{parameter.Data.ToHexString()}"); | |||||
base.Processor(parameter); | |||||
} | |||||
} | |||||
} |
@@ -1,42 +0,0 @@ | |||||
using JT808.Gateway.BusinessServices.ReplyMessage; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Protocol; | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.ReplyMessage.Test | |||||
{ | |||||
class Program | |||||
{ | |||||
async static Task Main(string[] args) | |||||
{ | |||||
var hostBuilder = new HostBuilder() | |||||
.UseEnvironment(args[0].Split('=')[1]) | |||||
.ConfigureAppConfiguration((hostContext, config) => { | |||||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |||||
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); | |||||
}) | |||||
.ConfigureLogging((hostContext, configLogging) => { | |||||
configLogging.AddConsole(); | |||||
configLogging.SetMinimumLevel(LogLevel.Trace); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => { | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddJT808Configure() | |||||
.AddJT808ClientKafka() | |||||
.AddMsgConsumer(hostContext.Configuration) | |||||
.AddMsgReplyProducer(hostContext.Configuration) | |||||
.AddInprocJT808ReplyMessage<JT808DotNettyReplyMessageServiceInherited>(); | |||||
}) | |||||
; | |||||
await hostBuilder.RunConsoleAsync(); | |||||
} | |||||
} | |||||
} |
@@ -1,24 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,41 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
using JT808.Gateway.BusinessServices.SessionNotice; | |||||
using JT808.Gateway.Configs.Kafka; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Gateway.PubSub; | |||||
using Microsoft.Extensions.Logging; | |||||
namespace JT808.Gateway.SessionNotice.Test | |||||
{ | |||||
public class JT808DotNettySessionNoticeServiceInherited : JT808SessionNoticeService | |||||
{ | |||||
public JT808DotNettySessionNoticeServiceInherited(ILoggerFactory loggerFactory) : base(loggerFactory) | |||||
{ | |||||
Task.Run(()=> { | |||||
while (true) | |||||
{ | |||||
Thread.Sleep(5000); | |||||
JT808SessionProducerConfig JT808ProducerConfig = new JT808SessionProducerConfig | |||||
{ | |||||
TopicName = "JT808Session", | |||||
BootstrapServers = "127.0.0.1:9092" | |||||
}; | |||||
using (IJT808SessionProducer jT808MsgProducer = new JT808SessionProducer(JT808ProducerConfig)) | |||||
{ | |||||
jT808MsgProducer.ProduceAsync("online", "123456").Wait(); | |||||
jT808MsgProducer.ProduceAsync("offline", "123457").Wait(); | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
public override void Processor((string Notice, string TerminalNo) parameter) | |||||
{ | |||||
base.Processor(parameter); | |||||
} | |||||
} | |||||
} |
@@ -1,41 +0,0 @@ | |||||
using JT808.Gateway.BusinessServices.SessionNotice; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Protocol; | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.SessionNotice.Test | |||||
{ | |||||
class Program | |||||
{ | |||||
async static Task Main(string[] args) | |||||
{ | |||||
var hostBuilder = new HostBuilder() | |||||
.UseEnvironment(args[0].Split('=')[1]) | |||||
.ConfigureAppConfiguration((hostContext, config) => { | |||||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |||||
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); | |||||
}) | |||||
.ConfigureLogging((hostContext, configLogging) => { | |||||
configLogging.AddConsole(); | |||||
configLogging.SetMinimumLevel(LogLevel.Trace); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => { | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddJT808Configure() | |||||
.AddJT808ClientKafka() | |||||
.AddSessionConsumer(hostContext.Configuration) | |||||
.AddInprocJT808SessionNotice<JT808DotNettySessionNoticeServiceInherited>(); | |||||
}) | |||||
; | |||||
await hostBuilder.RunConsoleAsync(); | |||||
} | |||||
} | |||||
} |
@@ -1,32 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
<IsPackable>false</IsPackable> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" /> | |||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> | |||||
<PackageReference Include="xunit" Version="2.4.0" /> | |||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | |||||
<PackageReference Include="coverlet.collector" Version="1.0.1" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="Tcp\appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
<None Update="Udp\appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,94 +0,0 @@ | |||||
using JT808.Protocol; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Net; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using JT808.Protocol.Extensions; | |||||
using Xunit; | |||||
using JT808.Gateway.Interfaces; | |||||
using JT808.Gateway.Session; | |||||
using JT808.Gateway.Simples; | |||||
namespace JT808.Gateway.Test.Tcp | |||||
{ | |||||
public class JT808SessionServiceTest:TestBase,IDisposable | |||||
{ | |||||
static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6565); | |||||
JT808SimpleTcpClient SimpleTcpClient1; | |||||
JT808SimpleTcpClient SimpleTcpClient2; | |||||
JT808SimpleTcpClient SimpleTcpClient3; | |||||
JT808SimpleTcpClient SimpleTcpClient4; | |||||
JT808SimpleTcpClient SimpleTcpClient5; | |||||
public JT808SessionServiceTest() | |||||
{ | |||||
SimpleTcpClient1 = new JT808SimpleTcpClient(endPoint); | |||||
SimpleTcpClient2 = new JT808SimpleTcpClient(endPoint); | |||||
SimpleTcpClient3 = new JT808SimpleTcpClient(endPoint); | |||||
SimpleTcpClient4 = new JT808SimpleTcpClient(endPoint); | |||||
SimpleTcpClient5 = new JT808SimpleTcpClient(endPoint); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); | |||||
SimpleTcpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); | |||||
SimpleTcpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); | |||||
SimpleTcpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); | |||||
SimpleTcpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); | |||||
SimpleTcpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); | |||||
Thread.Sleep(1000); | |||||
} | |||||
public void Dispose() | |||||
{ | |||||
SimpleTcpClient1.Down(); | |||||
SimpleTcpClient2.Down(); | |||||
SimpleTcpClient3.Down(); | |||||
SimpleTcpClient4.Down(); | |||||
SimpleTcpClient5.Down(); | |||||
} | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
var result = jT808SessionServiceDefaultImpl.GetTcpAll(); | |||||
Thread.Sleep(5000); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
var result1 = jT808SessionServiceDefaultImpl.GetTcpAll(); | |||||
var result2 = jT808SessionServiceDefaultImpl.RemoveByTerminalPhoneNo("123456789001"); | |||||
var result3 = jT808SessionServiceDefaultImpl.GetTcpAll(); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
// 判断通道是否关闭 | |||||
IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
JT808SessionManager jT808TcpSessionManager = ServiceProvider.GetService<JT808SessionManager>(); | |||||
var result1 = jT808SessionServiceDefaultImpl.GetTcpAll(); | |||||
SimpleTcpClient1.Down(); | |||||
Thread.Sleep(5000); | |||||
var session = jT808TcpSessionManager.GetSessionByTerminalPhoneNo("123456789001"); | |||||
Thread.Sleep(100000); | |||||
} | |||||
} | |||||
} |
@@ -1,75 +0,0 @@ | |||||
using JT808.Protocol; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Net; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Gateway.Interfaces; | |||||
using JT808.Gateway.Simples; | |||||
using Xunit; | |||||
using JT808.Gateway.Dtos; | |||||
namespace JT808.Gateway.Test.Tcp | |||||
{ | |||||
public class JT808UnificationTcpSendServiceTest: TestBase | |||||
{ | |||||
static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6565); | |||||
private IJT808UnificationSendService jT808UnificationSendService; | |||||
private IJT808SessionService jT808SessionServiceDefaultImpl; | |||||
public JT808UnificationTcpSendServiceTest() | |||||
{ | |||||
JT808SimpleTcpClient SimpleTcpClient1 = new JT808SimpleTcpClient(endPoint); | |||||
JT808SimpleTcpClient SimpleTcpClient2 = new JT808SimpleTcpClient(endPoint); | |||||
JT808SimpleTcpClient SimpleTcpClient3 = new JT808SimpleTcpClient(endPoint); | |||||
JT808SimpleTcpClient SimpleTcpClient4 = new JT808SimpleTcpClient(endPoint); | |||||
JT808SimpleTcpClient SimpleTcpClient5 = new JT808SimpleTcpClient(endPoint); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); | |||||
SimpleTcpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); | |||||
SimpleTcpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); | |||||
SimpleTcpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); | |||||
SimpleTcpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); | |||||
SimpleTcpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); | |||||
Thread.Sleep(300); | |||||
} | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
jT808UnificationSendService = ServiceProvider.GetService<IJT808UnificationSendService>(); | |||||
jT808SessionServiceDefaultImpl.GetTcpAll(); | |||||
string no = "123456789001"; | |||||
// 文本信息包 | |||||
JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.文本信息下发.Create(no, new JT808_0x8300 | |||||
{ | |||||
TextFlag = 5, | |||||
TextInfo = "smallchi 518" | |||||
}); | |||||
var data = JT808Serializer.Serialize(jT808Package2); | |||||
JT808ResultDto<bool> jt808Result = jT808UnificationSendService.Send(no, data); | |||||
Thread.Sleep(1000); | |||||
Assert.Equal(200, jt808Result.Code); | |||||
Assert.True(jt808Result.Data); | |||||
} | |||||
} | |||||
} |
@@ -1,43 +0,0 @@ | |||||
using JT808.Gateway.Tcp; | |||||
using JT808.Protocol; | |||||
using JT808.Protocol.Interfaces; | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO; | |||||
using System.Text; | |||||
namespace JT808.Gateway.Test.Tcp | |||||
{ | |||||
public class TestBase | |||||
{ | |||||
public static IServiceProvider ServiceProvider; | |||||
public static JT808Serializer JT808Serializer; | |||||
static TestBase() | |||||
{ | |||||
var serverHostBuilder = new HostBuilder() | |||||
.ConfigureAppConfiguration((hostingContext, config) => | |||||
{ | |||||
config.SetBasePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tcp")); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => | |||||
{ | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddJT808Configure() | |||||
.AddJT808Gateway(hostContext.Configuration) | |||||
.AddJT808GatewayTcpHost() | |||||
.Builder(); | |||||
//.Replace<>; | |||||
}); | |||||
var build = serverHostBuilder.Build(); | |||||
build.Start(); | |||||
ServiceProvider = build.Services; | |||||
JT808Serializer = ServiceProvider.GetRequiredService<IJT808Config>().GetSerializer(); | |||||
} | |||||
} | |||||
} |
@@ -1,92 +0,0 @@ | |||||
using JT808.Protocol; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Net; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using JT808.Protocol.Extensions; | |||||
using Xunit; | |||||
using JT808.Gateway.Simples; | |||||
using JT808.Gateway.Interfaces; | |||||
using JT808.Gateway.Session; | |||||
namespace JT808.Gateway.Test.Udp | |||||
{ | |||||
public class JT808SessionServiceTest:TestBase,IDisposable | |||||
{ | |||||
static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 818); | |||||
JT808SimpleUdpClient SimpleUdpClient1; | |||||
JT808SimpleUdpClient SimpleUdpClient2; | |||||
JT808SimpleUdpClient SimpleUdpClient3; | |||||
JT808SimpleUdpClient SimpleUdpClient4; | |||||
JT808SimpleUdpClient SimpleUdpClient5; | |||||
public void Dispose() | |||||
{ | |||||
SimpleUdpClient1.Down(); | |||||
SimpleUdpClient2.Down(); | |||||
SimpleUdpClient3.Down(); | |||||
SimpleUdpClient4.Down(); | |||||
SimpleUdpClient5.Down(); | |||||
} | |||||
public JT808SessionServiceTest() | |||||
{ | |||||
SimpleUdpClient1 = new JT808SimpleUdpClient(endPoint); | |||||
SimpleUdpClient2 = new JT808SimpleUdpClient(endPoint); | |||||
SimpleUdpClient3 = new JT808SimpleUdpClient(endPoint); | |||||
SimpleUdpClient4 = new JT808SimpleUdpClient(endPoint); | |||||
SimpleUdpClient5 = new JT808SimpleUdpClient(endPoint); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); | |||||
SimpleUdpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); | |||||
SimpleUdpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); | |||||
SimpleUdpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); | |||||
SimpleUdpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); | |||||
SimpleUdpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); | |||||
Thread.Sleep(1000); | |||||
} | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
var result = jT808SessionServiceDefaultImpl.GetUdpAll(); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
var result1 = jT808SessionServiceDefaultImpl.GetUdpAll(); | |||||
var result2 = jT808SessionServiceDefaultImpl.RemoveByTerminalPhoneNo("123456789001"); | |||||
var result3 = jT808SessionServiceDefaultImpl.GetUdpAll(); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
// 判断通道是否关闭 | |||||
IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
JT808SessionManager jT808UdpSessionManager = ServiceProvider.GetService<JT808SessionManager>(); | |||||
var result1 = jT808SessionServiceDefaultImpl.GetUdpAll(); | |||||
SimpleUdpClient1.Down(); | |||||
var session = jT808UdpSessionManager.GetSessionByTerminalPhoneNo("123456789001"); | |||||
var result3 = jT808UdpSessionManager.GetUdpAll(); | |||||
Thread.Sleep(100000); | |||||
} | |||||
} | |||||
} |
@@ -1,76 +0,0 @@ | |||||
using JT808.Protocol; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Net; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Gateway.Interfaces; | |||||
using JT808.Gateway.Simples; | |||||
using JT808.Gateway.Dtos; | |||||
using Xunit; | |||||
namespace JT808.Gateway.Test.Udp | |||||
{ | |||||
public class JT808UnificationUdpSendServiceTest : TestBase | |||||
{ | |||||
static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 818); | |||||
private IJT808UnificationSendService jT808UnificationSendService; | |||||
private IJT808SessionService jT808SessionServiceDefaultImpl; | |||||
public JT808UnificationUdpSendServiceTest() | |||||
{ | |||||
JT808SimpleUdpClient SimpleUdpClient1 = new JT808SimpleUdpClient(endPoint); | |||||
JT808SimpleUdpClient SimpleUdpClient2 = new JT808SimpleUdpClient(endPoint); | |||||
JT808SimpleUdpClient SimpleUdpClient3 = new JT808SimpleUdpClient(endPoint); | |||||
JT808SimpleUdpClient SimpleUdpClient4 = new JT808SimpleUdpClient(endPoint); | |||||
JT808SimpleUdpClient SimpleUdpClient5 = new JT808SimpleUdpClient(endPoint); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); | |||||
SimpleUdpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); | |||||
SimpleUdpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); | |||||
SimpleUdpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); | |||||
SimpleUdpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); | |||||
// 心跳会话包 | |||||
JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); | |||||
SimpleUdpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); | |||||
Thread.Sleep(300); | |||||
} | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
//"126 131 0 0 13 18 52 86 120 144 1 0 11 5 115 109 97 108 108 99 104 105 32 53 49 56 24 126" | |||||
jT808SessionServiceDefaultImpl = ServiceProvider.GetService<IJT808SessionService>(); | |||||
jT808UnificationSendService = ServiceProvider.GetService<IJT808UnificationSendService>(); | |||||
jT808SessionServiceDefaultImpl.GetUdpAll(); | |||||
string no = "123456789001"; | |||||
// 文本信息包 | |||||
JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.文本信息下发.Create(no, new JT808_0x8300 | |||||
{ | |||||
TextFlag = 5, | |||||
TextInfo = "smallchi 518" | |||||
}); | |||||
var data = JT808Serializer.Serialize(jT808Package2); | |||||
JT808ResultDto<bool> jt808Result = jT808UnificationSendService.Send(no, data); | |||||
Thread.Sleep(1000); | |||||
Assert.Equal(200, jt808Result.Code); | |||||
Assert.True(jt808Result.Data); | |||||
} | |||||
} | |||||
} |
@@ -1,41 +0,0 @@ | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using JT808.Protocol; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Gateway.Udp; | |||||
using System.IO; | |||||
namespace JT808.Gateway.Test.Udp | |||||
{ | |||||
public class TestBase | |||||
{ | |||||
public static IServiceProvider ServiceProvider; | |||||
public static JT808Serializer JT808Serializer; | |||||
static TestBase() | |||||
{ | |||||
var serverHostBuilder = new HostBuilder() | |||||
.ConfigureAppConfiguration((hostingContext, config) => | |||||
{ | |||||
config.SetBasePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Udp")); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => | |||||
{ | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddJT808Configure() | |||||
.AddJT808Gateway(hostContext.Configuration) | |||||
.AddJT808GatewayUdpHost(); | |||||
}); | |||||
var build = serverHostBuilder.Build(); | |||||
build.Start(); | |||||
ServiceProvider = build.Services; | |||||
JT808Serializer = ServiceProvider.GetRequiredService<IJT808Config>().GetSerializer(); | |||||
} | |||||
} | |||||
} |
@@ -1,24 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,40 +0,0 @@ | |||||
using JT808.Gateway.Configs.Kafka; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Gateway.PubSub; | |||||
using JT808.Protocol.Extensions; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.Traffic.Test | |||||
{ | |||||
public class JT808DotNettyTrafficServiceTest | |||||
{ | |||||
private readonly CSRedis.CSRedisClient redisClien; | |||||
public readonly ILogger<JT808DotNettyTrafficServiceTest> logger; | |||||
public JT808DotNettyTrafficServiceTest(ILoggerFactory loggerFactory) { | |||||
redisClien = new CSRedis.CSRedisClient("127.0.0.1:6379,password=smallchi"); | |||||
RedisHelper.Initialization(redisClien); | |||||
logger = loggerFactory.CreateLogger<JT808DotNettyTrafficServiceTest>(); | |||||
Task.Run(() => { | |||||
while (true) | |||||
{ | |||||
Thread.Sleep(5000); | |||||
using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig | |||||
{ | |||||
BootstrapServers = "127.0.0.1:9092", | |||||
TopicName = "JT808Msg" | |||||
})) | |||||
{ | |||||
jT808MsgProducer.ProduceAsync("011111111111", "7E02000032011111111111012E00000000000C00000160E42506C30C82002C00000000180914142057010400001DC003020000250400000000300115310100977E".ToHexBytes()).Wait(); | |||||
} | |||||
var length= RedisHelper.HGet("011111111111", DateTime.Now.ToString("yyyyMMdd")); | |||||
logger.LogDebug($"{011111111111}:{length}"); | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
} |
@@ -1,44 +0,0 @@ | |||||
using JT808.Gateway.BusinessServices.Traffic; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Protocol; | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.Traffic.Test | |||||
{ | |||||
class Program | |||||
{ | |||||
async static Task Main(string[] args) | |||||
{ | |||||
var hostBuilder = new HostBuilder() | |||||
.UseEnvironment(args[0].Split('=')[1]) | |||||
.ConfigureAppConfiguration((hostContext, config) => { | |||||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |||||
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); | |||||
}) | |||||
.ConfigureLogging((hostContext, configLogging) => { | |||||
configLogging.AddConsole(); | |||||
configLogging.SetMinimumLevel(LogLevel.Trace); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => { | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddSingleton<JT808DotNettyTrafficServiceTest>(); | |||||
services.AddJT808Configure() | |||||
.AddJT808ClientKafka() | |||||
.AddMsgConsumer(hostContext.Configuration) | |||||
.AddInprocJT808Traffic(); | |||||
services.BuildServiceProvider().GetRequiredService<JT808DotNettyTrafficServiceTest>(); | |||||
}) | |||||
; | |||||
await hostBuilder.RunConsoleAsync(); | |||||
} | |||||
} | |||||
} |
@@ -1,24 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="appsettings.json"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,35 +0,0 @@ | |||||
using JT808.Gateway.Configs.Kafka; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Gateway.PubSub; | |||||
using JT808.Protocol.Extensions; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.Transmit.Test | |||||
{ | |||||
public class JT808DotNettyTransmitServiceTest | |||||
{ | |||||
public readonly ILogger<JT808DotNettyTransmitServiceTest> logger; | |||||
public JT808DotNettyTransmitServiceTest(ILoggerFactory loggerFactory) { | |||||
logger = loggerFactory.CreateLogger<JT808DotNettyTransmitServiceTest>(); | |||||
Task.Run(() => { | |||||
while (true) | |||||
{ | |||||
Thread.Sleep(5000); | |||||
using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig | |||||
{ | |||||
BootstrapServers = "127.0.0.1:9092", | |||||
TopicName = "JT808Msg" | |||||
})) | |||||
{ | |||||
jT808MsgProducer.ProduceAsync("011111111111", "7E02000032011111111111012E00000000000C00000160E42506C30C82002C00000000180914142057010400001DC003020000250400000000300115310100977E".ToHexBytes()).Wait(); | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
} |
@@ -1,43 +0,0 @@ | |||||
using JT808.Gateway.BusinessServices.Transmit; | |||||
using JT808.Gateway.Kafka; | |||||
using JT808.Protocol; | |||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
namespace JT808.Gateway.Transmit.Test | |||||
{ | |||||
class Program | |||||
{ | |||||
async static Task Main(string[] args) | |||||
{ | |||||
var hostBuilder = new HostBuilder() | |||||
.UseEnvironment(args[0].Split('=')[1]) | |||||
.ConfigureAppConfiguration((hostContext, config) => { | |||||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |||||
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); | |||||
}) | |||||
.ConfigureLogging((hostContext, configLogging) => { | |||||
configLogging.AddConsole(); | |||||
configLogging.SetMinimumLevel(LogLevel.Trace); | |||||
}) | |||||
.ConfigureServices((hostContext, services) => { | |||||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||||
services.AddSingleton<JT808DotNettyTransmitServiceTest>(); | |||||
services.AddJT808Configure() | |||||
.AddJT808ClientKafka() | |||||
.AddMsgConsumer(hostContext.Configuration) | |||||
.AddInprocJT808Transmit(hostContext.Configuration); | |||||
services.BuildServiceProvider().GetRequiredService<JT808DotNettyTransmitServiceTest>(); | |||||
}) | |||||
; | |||||
await hostBuilder.RunConsoleAsync(); | |||||
} | |||||
} | |||||
} |