From fd11350e5e66032139eaf7da2b6bc9a7e8d8da8f Mon Sep 17 00:00:00 2001 From: "smallchi(Koike)" <564952747@qq.com> Date: Sun, 2 Feb 2020 20:53:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=B9=B6=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E7=AE=80=E5=8D=95demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JT808.Gateway.SimpleClient.csproj | 4 ++-- .../Impl/JT808MsgIdHandler.cs | 22 +++++++++++++++++++ .../Impl/JT808MsgLogging.cs | 22 +++++++++++++++++++ .../JT808.Gateway.SimpleServer.csproj | 10 ++++++--- simples/JT808.Gateway.SimpleServer/Program.cs | 16 ++++++++++++-- 5 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 simples/JT808.Gateway.SimpleServer/Impl/JT808MsgIdHandler.cs create mode 100644 simples/JT808.Gateway.SimpleServer/Impl/JT808MsgLogging.cs diff --git a/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj b/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj index e110975..33c35ca 100644 --- a/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj +++ b/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/simples/JT808.Gateway.SimpleServer/Impl/JT808MsgIdHandler.cs b/simples/JT808.Gateway.SimpleServer/Impl/JT808MsgIdHandler.cs new file mode 100644 index 0000000..3d62db0 --- /dev/null +++ b/simples/JT808.Gateway.SimpleServer/Impl/JT808MsgIdHandler.cs @@ -0,0 +1,22 @@ +using JT808.Gateway.MsgIdHandler; +using JT808.Protocol.Extensions; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Gateway.SimpleServer.Impl +{ + public class JT808MsgIdHandler : IJT808MsgIdHandler + { + private readonly ILogger Logger; + public JT808MsgIdHandler(ILoggerFactory loggerFactory) + { + Logger = loggerFactory.CreateLogger("JT808MsgIdHandler"); + } + public void Processor((string TerminalNo, byte[] Data) parameter) + { + Logger.LogDebug($"{parameter.TerminalNo}-{parameter.Data.ToHexString()}"); + } + } +} diff --git a/simples/JT808.Gateway.SimpleServer/Impl/JT808MsgLogging.cs b/simples/JT808.Gateway.SimpleServer/Impl/JT808MsgLogging.cs new file mode 100644 index 0000000..61c827f --- /dev/null +++ b/simples/JT808.Gateway.SimpleServer/Impl/JT808MsgLogging.cs @@ -0,0 +1,22 @@ +using JT808.Gateway.MsgLogging; +using JT808.Protocol.Extensions; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Gateway.SimpleServer.Impl +{ + public class JT808MsgLogging : IJT808MsgLogging + { + private readonly ILogger Logger; + public JT808MsgLogging(ILoggerFactory loggerFactory) + { + Logger = loggerFactory.CreateLogger("JT808MsgLogging"); + } + public void Processor((string TerminalNo, byte[] Data) parameter, JT808MsgLoggingType jT808MsgLoggingType) + { + Logger.LogDebug($"{jT808MsgLoggingType.ToString()}-{parameter.TerminalNo}-{parameter.Data.ToHexString()}"); + } + } +} diff --git a/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj b/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj index 89e6702..45e6730 100644 --- a/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj +++ b/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj @@ -5,9 +5,13 @@ netcoreapp3.1 - - - + + + + + + + diff --git a/simples/JT808.Gateway.SimpleServer/Program.cs b/simples/JT808.Gateway.SimpleServer/Program.cs index 2457ae6..5825865 100644 --- a/simples/JT808.Gateway.SimpleServer/Program.cs +++ b/simples/JT808.Gateway.SimpleServer/Program.cs @@ -1,5 +1,10 @@ -using JT808.Gateway.InMemoryMQ; +using JT808.Gateway.Abstractions.Enums; +using JT808.Gateway.InMemoryMQ; using JT808.Gateway.ReplyMessage; +using JT808.Gateway.MsgLogging; +using JT808.Gateway.Traffic; +using JT808.Gateway.MsgIdHandler; +using JT808.Gateway.SessionNotice; using JT808.Protocol; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -8,6 +13,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System; using System.Threading.Tasks; +using JT808.Gateway.SimpleServer.Impl; namespace JT808.Gateway.SimpleServer { @@ -33,8 +39,14 @@ namespace JT808.Gateway.SimpleServer services.AddJT808Configure() .AddGateway(hostContext.Configuration) .AddTcp() - .AddServerInMemoryMQ() + .AddServerInMemoryMQ(JT808ConsumerType.MsgIdHandlerConsumer| + JT808ConsumerType.ReplyMessageConsumer | + JT808ConsumerType.MsgLoggingConsumer | + JT808ConsumerType.ReplyMessageLoggingConsumer) + .AddInMemoryMsgIdHandler() .AddInMemoryReplyMessage() + .AddInMemoryMsgLogging() + .AddInMemorySessionNotice() .Builder(); });