浏览代码

1.调整消息应答注册服务

2.去掉构建网关的扩展注册方法
3.调整客户端测试工具默认打开index.html
4.调整客户端测试工具为signalr输出报表
tags/pipeline-1.1.0
SmallChi(Koike) 4 年前
父节点
当前提交
27179ede92
共有 17 个文件被更改,包括 294 次插入97 次删除
  1. +12
    -0
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Hubs/ReportHub.cs
  2. +12
    -0
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/JT808.Gateway.CleintBenchmark.csproj
  3. +7
    -1
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Program.cs
  4. +13
    -10
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs
  5. +77
    -0
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/QueryReportHostedService.cs
  6. +3
    -0
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/axios.min.js
  7. +1
    -0
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/day.js
  8. +95
    -47
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/index.html
  9. +17
    -0
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/signalr.min.js
  10. +1
    -1
      src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs
  11. +1
    -2
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs
  12. +1
    -2
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs
  13. +2
    -2
      src/JT808.Gateway.Tests/JT808.Gateway.Test/Session/JT808SessionManagerTest.cs
  14. +14
    -14
      src/JT808.Gateway.sln
  15. +35
    -0
      src/JT808.Gateway/Internal/JT808MsgReplyConsumer_Empry.cs
  16. +0
    -6
      src/JT808.Gateway/JT808.Gateway.xml
  17. +3
    -12
      src/JT808.Gateway/JT808GatewayExtensions.cs

+ 12
- 0
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Hubs/ReportHub.cs 查看文件

@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace JT808.Gateway.CleintBenchmark.Hubs
{
public class ReportHub : Hub
{
}
}

+ 12
- 0
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/JT808.Gateway.CleintBenchmark.csproj 查看文件

@@ -7,8 +7,11 @@
</PropertyGroup>

<ItemGroup>
<Content Remove="wwwroot\axios.min.js" />
<Content Remove="wwwroot\day.js" />
<Content Remove="wwwroot\echarts.min.js" />
<Content Remove="wwwroot\index.html" />
<Content Remove="wwwroot\signalr.min.js" />
</ItemGroup>

<ItemGroup>
@@ -24,6 +27,12 @@
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" />
<None Include="wwwroot\axios.min.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="wwwroot\day.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="wwwroot\echarts.min.js">
@@ -32,6 +41,9 @@
<None Include="wwwroot\index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="wwwroot\signalr.min.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>


+ 7
- 1
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Program.cs 查看文件

@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Builder;
using JT808.Gateway.Client;
using JT808.Gateway.CleintBenchmark.Configs;
using JT808.Gateway.CleintBenchmark.Services;
using JT808.Gateway.CleintBenchmark.Hubs;

namespace JT808.Gateway.CleintBenchmark
{
@@ -31,14 +32,17 @@ namespace JT808.Gateway.CleintBenchmark
app.UseRouting();
app.UseCors("Domain");
app.UseStaticFiles();
app.UseDefaultFiles("/index.html");
app.UseDefaultFiles();
app.UseFileServer();
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<ReportHub>("/ReportHub");
endpoints.MapControllers();
});
})
.ConfigureServices((hostContext, services) =>
{
services.AddControllers();
services.AddCors(options =>
options.AddPolicy("Domain", builder =>
@@ -46,6 +50,7 @@ namespace JT808.Gateway.CleintBenchmark
.AllowAnyMethod()
.AllowAnyHeader()
.AllowAnyOrigin()));
services.AddSignalR();

});
})
@@ -71,6 +76,7 @@ namespace JT808.Gateway.CleintBenchmark
.AddClient()
.AddClientReport();
services.AddHostedService<CleintBenchmarkHostedService>();
services.AddHostedService<QueryReportHostedService>();
});
await serverHostBuilder.RunConsoleAsync();
}


+ 13
- 10
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs 查看文件

@@ -58,17 +58,20 @@ namespace JT808.Gateway.CleintBenchmark.Services
{
int lat = new Random(1000).Next(100000, 180000);
int Lng = new Random(1000).Next(100000, 180000);
await client.SendAsync(JT808MsgId.位置信息汇报.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200()
if (client != null)
{
Lat = lat,
Lng = Lng,
GPSTime = DateTime.Now,
Speed = 50,
Direction = 30,
AlarmFlag = 5,
Altitude = 50,
StatusFlag = 10
}));
await client.SendAsync(JT808MsgId.位置信息汇报.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200()
{
Lat = lat,
Lng = Lng,
GPSTime = DateTime.Now,
Speed = 50,
Direction = 30,
AlarmFlag = 5,
Altitude = 50,
StatusFlag = 10
}));
}
}
catch (Exception ex)
{


+ 77
- 0
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/QueryReportHostedService.cs 查看文件

@@ -0,0 +1,77 @@
using JT808.Gateway.CleintBenchmark.Configs;
using JT808.Gateway.CleintBenchmark.Hubs;
using JT808.Gateway.Client;
using JT808.Gateway.Client.Metadata;
using JT808.Gateway.Client.Services;
using JT808.Protocol.Enums;
using JT808.Protocol.Extensions;
using JT808.Protocol.MessageBody;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Text.Json;


namespace JT808.Gateway.CleintBenchmark.Services
{
public class QueryReportHostedService : BackgroundService
{
private readonly IJT808TcpClientFactory clientFactory;
private readonly JT808ReceiveAtomicCounterService ReceiveAtomicCounterService;
private readonly JT808SendAtomicCounterService SendAtomicCounterService;
private readonly ILogger logger;
private readonly IHubContext<ReportHub> _hubContext;

public QueryReportHostedService(
ILoggerFactory loggerFactory,
IHubContext<ReportHub> hubContext,
JT808ReceiveAtomicCounterService jT808ReceiveAtomicCounterService,
JT808SendAtomicCounterService jT808SendAtomicCounterService,
IJT808TcpClientFactory clientFactory)
{
this.clientFactory = clientFactory;
this._hubContext = hubContext;
logger = loggerFactory.CreateLogger<QueryReportHostedService>();
ReceiveAtomicCounterService = jT808ReceiveAtomicCounterService;
SendAtomicCounterService = jT808SendAtomicCounterService;

}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
try
{
var clients = clientFactory.GetAll();
JT808Report report = new JT808Report()
{
SendTotalCount = SendAtomicCounterService.MsgSuccessCount,
ReceiveTotalCount = ReceiveAtomicCounterService.MsgSuccessCount,
CurrentDate = DateTime.Now,
Connections = clients.Count,
OnlineConnections = clients.Where(w => w.IsOpen).Count(),
OfflineConnections = clients.Where(w => !w.IsOpen).Count(),
};
await _hubContext.Clients.All.SendAsync("ReceiveMessage", "query", JsonSerializer.Serialize(report));
}
catch (Exception ex)
{
logger.LogError(ex, "");
}
finally
{
await Task.Delay(TimeSpan.FromSeconds(1), stoppingToken);
}
}
}
}
}

+ 3
- 0
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/axios.min.js
文件差异内容过多而无法显示
查看文件


+ 1
- 0
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/day.js
文件差异内容过多而无法显示
查看文件


+ 95
- 47
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/index.html 查看文件

@@ -4,9 +4,10 @@
<head>
<meta charset="utf-8" />
<title>收发查看</title>
<script src="https://unpkg.com/dayjs"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="/day.js"></script>
<script src="/axios.min.js"></script>
<script src="/echarts.min.js"></script>
<script src="/signalr.min.js"></script>
</head>

<body>
@@ -96,51 +97,98 @@
data: offlineData
}]
};
setInterval(function () {
axios.post('http://localhost:5000/JT808WebApi/QueryReport')
.then((response) => {
if (response.data) {
if(sendData.length>16){
sendData.shift();
receiveData.shift();
onlineData.shift();
offlineData.shift();
timeData.shift();
}
//console.log(response.data);
timeData.push(dayjs(response.data.currentDate).format('HH:mm:ss'));
sendData.push(response.data.sendTotalCount);
receiveData.push(response.data.receiveTotalCount);
onlineData.push(response.data.onlineConnections);
offlineData.push(response.data.offlineConnections);
tcpChart.setOption({
series: [{
data: sendData
},{
data: receiveData
}],
xAxis:[{
data: timeData
}]
});
connChart.setOption({
series: [{
data: onlineData
},{
data: offlineData
}],
xAxis:[{
data: timeData
}]
});
} else {
alert("没有数据");
}
})
.catch((error) => {
console.log(error);
});
}, 1000);
//setInterval(function () {
// axios.post('/JT808WebApi/QueryReport')
// .then((response) => {
// if (response.data) {
// if(sendData.length>16){
// sendData.shift();
// receiveData.shift();
// onlineData.shift();
// offlineData.shift();
// timeData.shift();
// }
// //console.log(response.data);
// timeData.push(dayjs(response.data.currentDate).format('HH:mm:ss'));
// sendData.push(response.data.sendTotalCount);
// receiveData.push(response.data.receiveTotalCount);
// onlineData.push(response.data.onlineConnections);
// offlineData.push(response.data.offlineConnections);
// tcpChart.setOption({
// series: [{
// data: sendData
// },{
// data: receiveData
// }],
// xAxis:[{
// data: timeData
// }]
// });
// connChart.setOption({
// series: [{
// data: onlineData
// },{
// data: offlineData
// }],
// xAxis:[{
// data: timeData
// }]
// });
// } else {
// alert("没有数据");
// }
// })
// .catch((error) => {
// console.log(error);
// });
//}, 1000);
this.signalrInfo = {};
//todo:根据底图动态切换皮肤 第二版再搞
this.signalrInfo.conn = new signalR.HubConnectionBuilder()
.withUrl("/ReportHub")
.withAutomaticReconnect({
nextRetryDelayInMilliseconds: retryContext => {
return 8000;
}
})
.build();
this.signalrInfo.conn.on("ReceiveMessage", (key, message) => {
message = JSON.parse(message);
//console.debug("ReceiveMessage",key, message);
if (sendData.length > 16) {
sendData.shift();
receiveData.shift();
onlineData.shift();
offlineData.shift();
timeData.shift();
}
timeData.push(dayjs(message.CurrentDate).format('HH:mm:ss'));
sendData.push(message.SendTotalCount);
receiveData.push(message.ReceiveTotalCount);
onlineData.push(message.OnlineConnections);
offlineData.push(message.OfflineConnections);
tcpChart.setOption({
series: [{
data: sendData
}, {
data: receiveData
}],
xAxis: [{
data: timeData
}]
});
connChart.setOption({
series: [{
data: onlineData
}, {
data: offlineData
}],
xAxis: [{
data: timeData
}]
});
});
this.signalrInfo.conn.start().catch(err => console.error(err));
if (tcpOption && typeof tcpOption === "object") {
tcpChart.setOption(tcpOption, true);
}


+ 17
- 0
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/wwwroot/signalr.min.js
文件差异内容过多而无法显示
查看文件


+ 1
- 1
src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs 查看文件

@@ -47,7 +47,7 @@ namespace JT808.Gateway.Kafka
public static IJT808ClientBuilder AddMsgReplyConsumer(this IJT808ClientBuilder jT808ClientBuilder, IConfiguration configuration)
{
jT808ClientBuilder.JT808Builder.Services.Configure<JT808MsgReplyConsumerConfig>(configuration.GetSection("JT808MsgReplyConsumerConfig"));
jT808ClientBuilder.JT808Builder.Services.TryAddSingleton<IJT808MsgReplyConsumer, JT808MsgReplyConsumer>();
jT808ClientBuilder.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808MsgReplyConsumer), typeof(JT808MsgReplyConsumer), ServiceLifetime.Singleton));
return jT808ClientBuilder;
}
/// <summary>


+ 1
- 2
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs 查看文件

@@ -59,8 +59,7 @@ namespace JT808.Gateway.NormalHosting
.AddTransmit(hostContext.Configuration)
.AddTcp()
.AddUdp()
.AddHttp()
.Register();//必须注册的
.AddHttp();
services.AddJT808WebApiClientTool(hostContext.Configuration);
//httpclient客户端调用
services.AddHostedService<CallHttpClientJob>();


+ 1
- 2
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs 查看文件

@@ -62,8 +62,7 @@ namespace JT808.Gateway.QueueHosting
.AddServerKafkaMsgReplyConsumer(hostContext.Configuration)
.AddTcp()
.AddUdp()
.AddHttp()
.Register();//必须注册的
.AddHttp();
services.AddJT808WebApiClientTool(hostContext.Configuration);
//httpclient客户端调用
services.AddHostedService<CallHttpClientJob>();


+ 2
- 2
src/JT808.Gateway.Tests/JT808.Gateway.Test/Session/JT808SessionManagerTest.cs 查看文件

@@ -151,14 +151,14 @@ namespace JT808.Gateway.Test.Session
[Fact]
public void SendTest()
{
Assert.Throws<SocketException>(() =>
Assert.ThrowsAsync<SocketException>(async () =>
{
string tno = "123456";
JT808SessionManager jT808SessionManager = new JT808SessionManager(new LoggerFactory());
var session = new JT808TcpSession(new Socket(SocketType.Stream, ProtocolType.Tcp));
var result1 = jT808SessionManager.TryAdd(session);
jT808SessionManager.TryLink(tno, session);
jT808SessionManager.TrySendByTerminalPhoneNoAsync(tno, new byte[] { 0x7e, 0, 0, 0x7e }).GetAwaiter().GetResult();
await jT808SessionManager.TrySendByTerminalPhoneNoAsync(tno, new byte[] { 0x7e, 0, 0, 0x7e });
});
}



+ 14
- 14
src/JT808.Gateway.sln 查看文件

@@ -29,14 +29,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.QueueHosting"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmark", "Benchmark", "{6FAEC008-93CB-4730-8C58-D31FFD342C4F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.CleintBenchmark", "JT808.Gateway.Benchmark\JT808.Gateway.CleintBenchmark\JT808.Gateway.CleintBenchmark.csproj", "{E34C6B7D-A48B-4871-895C-07AC12F959D3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.ServerBenchmark", "JT808.Gateway.Benchmark\JT808.Gateway.ServerBenchmark\JT808.Gateway.ServerBenchmark.csproj", "{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.WebApiClientTool", "JT808.Gateway.WebApiClientTool\JT808.Gateway.WebApiClientTool.csproj", "{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.ReplyMessage", "JT808.Gateway.Services\JT808.Gateway.ReplyMessage\JT808.Gateway.ReplyMessage.csproj", "{886D0A3F-C974-442B-9820-F1C4C04EAAB6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.ServerBenchmark", "JT808.Gateway.Benchmark\JT808.Gateway.ServerBenchmark\JT808.Gateway.ServerBenchmark.csproj", "{8B32DDBF-F118-4216-A49A-C067F6107D0A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.CleintBenchmark", "JT808.Gateway.Benchmark\JT808.Gateway.CleintBenchmark\JT808.Gateway.CleintBenchmark.csproj", "{45113CCF-2556-459F-B330-D0A5A885FC4C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -83,14 +83,6 @@ Global
{52D895BD-C60B-42D8-9229-C85927546FDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52D895BD-C60B-42D8-9229-C85927546FDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52D895BD-C60B-42D8-9229-C85927546FDA}.Release|Any CPU.Build.0 = Release|Any CPU
{E34C6B7D-A48B-4871-895C-07AC12F959D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E34C6B7D-A48B-4871-895C-07AC12F959D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E34C6B7D-A48B-4871-895C-07AC12F959D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E34C6B7D-A48B-4871-895C-07AC12F959D3}.Release|Any CPU.Build.0 = Release|Any CPU
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Release|Any CPU.Build.0 = Release|Any CPU
{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -99,6 +91,14 @@ Global
{886D0A3F-C974-442B-9820-F1C4C04EAAB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{886D0A3F-C974-442B-9820-F1C4C04EAAB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{886D0A3F-C974-442B-9820-F1C4C04EAAB6}.Release|Any CPU.Build.0 = Release|Any CPU
{8B32DDBF-F118-4216-A49A-C067F6107D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B32DDBF-F118-4216-A49A-C067F6107D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B32DDBF-F118-4216-A49A-C067F6107D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B32DDBF-F118-4216-A49A-C067F6107D0A}.Release|Any CPU.Build.0 = Release|Any CPU
{45113CCF-2556-459F-B330-D0A5A885FC4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45113CCF-2556-459F-B330-D0A5A885FC4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45113CCF-2556-459F-B330-D0A5A885FC4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45113CCF-2556-459F-B330-D0A5A885FC4C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -110,9 +110,9 @@ Global
{E3DC260E-0B55-4993-B051-402E44D4E883} = {7CBAACEE-19BF-499A-8C41-36A1324D45E9}
{22368AAD-A1F3-446B-B68F-98A0933BF1F6} = {7CBAACEE-19BF-499A-8C41-36A1324D45E9}
{52D895BD-C60B-42D8-9229-C85927546FDA} = {7CBAACEE-19BF-499A-8C41-36A1324D45E9}
{E34C6B7D-A48B-4871-895C-07AC12F959D3} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F}
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F}
{886D0A3F-C974-442B-9820-F1C4C04EAAB6} = {3EF8490D-C993-49D8-8A3D-493B7F259D70}
{8B32DDBF-F118-4216-A49A-C067F6107D0A} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F}
{45113CCF-2556-459F-B330-D0A5A885FC4C} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AA9303A7-6FB3-4572-88AA-3302E85330D1}


+ 35
- 0
src/JT808.Gateway/Internal/JT808MsgReplyConsumer_Empry.cs 查看文件

@@ -0,0 +1,35 @@
using JT808.Gateway.Abstractions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace JT808.Gateway.Internal
{
class JT808MsgReplyConsumer_Empry : IJT808MsgReplyConsumer
{
public CancellationTokenSource Cts { get; } = new CancellationTokenSource();

public string TopicName { get; } = JT808GatewayConstants.MsgReplyTopic;

public void Dispose()
{

}

public void OnMessage(Action<(string TerminalNo, byte[] Data)> callback)
{

}

public void Subscribe()
{

}

public void Unsubscribe()
{

}
}
}

+ 0
- 6
src/JT808.Gateway/JT808.Gateway.xml 查看文件

@@ -143,12 +143,6 @@
<param name="config"></param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.JT808GatewayExtensions.Register(JT808.Gateway.Abstractions.IJT808GatewayBuilder)">
<summary>
必须注册的
</summary>
<param name="config"></param>
</member>
<member name="M:JT808.Gateway.JT808GatewayExtensions.AddJT808Core(JT808.Gateway.Abstractions.IJT808GatewayBuilder)">
<summary>
添加公共模块


+ 3
- 12
src/JT808.Gateway/JT808GatewayExtensions.cs 查看文件

@@ -150,21 +150,10 @@ namespace JT808.Gateway
public static IJT808GatewayBuilder AddMsgReplyConsumer<TJT808MsgReplyConsumer>(this IJT808GatewayBuilder config)
where TJT808MsgReplyConsumer : IJT808MsgReplyConsumer
{
config.JT808Builder.Services.Add(new ServiceDescriptor(typeof(IJT808MsgReplyConsumer), typeof(TJT808MsgReplyConsumer), ServiceLifetime.Singleton));
config.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808MsgReplyConsumer), typeof(TJT808MsgReplyConsumer), ServiceLifetime.Singleton));
return config;
}
/// <summary>
/// 必须注册的
/// </summary>
/// <param name="config"></param>
public static void Register(this IJT808GatewayBuilder config)
{
if(config.JT808Builder.Services.Where(s => s.ServiceType == typeof(IJT808MsgReplyConsumer)).Count() > 0)
{
config.JT808Builder.Services.AddHostedService<JT808MsgReplyHostedService>();
}
}
/// <summary>
/// 添加公共模块
/// </summary>
/// <param name="config"></param>
@@ -175,6 +164,8 @@ namespace JT808.Gateway
config.JT808Builder.Services.AddSingleton<JT808SessionManager>();
config.JT808Builder.Services.AddSingleton<IJT808MsgProducer, JT808MsgProducer_Empty>();
config.JT808Builder.Services.AddSingleton<IJT808MsgReplyLoggingProducer, JT808MsgReplyLoggingProducer_Empty>();
config.JT808Builder.Services.AddSingleton<IJT808MsgReplyConsumer, JT808MsgReplyConsumer_Empry>();
config.JT808Builder.Services.AddHostedService<JT808MsgReplyHostedService>();
return config;
}
}

正在加载...
取消
保存