2.去掉构建网关的扩展注册方法 3.调整客户端测试工具默认打开index.html 4.调整客户端测试工具为signalr输出报表tags/pipeline-1.1.0
@@ -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 | |||||
{ | |||||
} | |||||
} |
@@ -7,8 +7,11 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<Content Remove="wwwroot\axios.min.js" /> | |||||
<Content Remove="wwwroot\day.js" /> | |||||
<Content Remove="wwwroot\echarts.min.js" /> | <Content Remove="wwwroot\echarts.min.js" /> | ||||
<Content Remove="wwwroot\index.html" /> | <Content Remove="wwwroot\index.html" /> | ||||
<Content Remove="wwwroot\signalr.min.js" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -24,6 +27,12 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" /> | <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> | ||||
<ItemGroup> | <ItemGroup> | ||||
<None Include="wwwroot\echarts.min.js"> | <None Include="wwwroot\echarts.min.js"> | ||||
@@ -32,6 +41,9 @@ | |||||
<None Include="wwwroot\index.html"> | <None Include="wwwroot\index.html"> | ||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||
</None> | </None> | ||||
<None Include="wwwroot\signalr.min.js"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Builder; | |||||
using JT808.Gateway.Client; | using JT808.Gateway.Client; | ||||
using JT808.Gateway.CleintBenchmark.Configs; | using JT808.Gateway.CleintBenchmark.Configs; | ||||
using JT808.Gateway.CleintBenchmark.Services; | using JT808.Gateway.CleintBenchmark.Services; | ||||
using JT808.Gateway.CleintBenchmark.Hubs; | |||||
namespace JT808.Gateway.CleintBenchmark | namespace JT808.Gateway.CleintBenchmark | ||||
{ | { | ||||
@@ -31,14 +32,17 @@ namespace JT808.Gateway.CleintBenchmark | |||||
app.UseRouting(); | app.UseRouting(); | ||||
app.UseCors("Domain"); | app.UseCors("Domain"); | ||||
app.UseStaticFiles(); | app.UseStaticFiles(); | ||||
app.UseDefaultFiles("/index.html"); | |||||
app.UseDefaultFiles(); | |||||
app.UseFileServer(); | |||||
app.UseEndpoints(endpoints => | app.UseEndpoints(endpoints => | ||||
{ | { | ||||
endpoints.MapHub<ReportHub>("/ReportHub"); | |||||
endpoints.MapControllers(); | endpoints.MapControllers(); | ||||
}); | }); | ||||
}) | }) | ||||
.ConfigureServices((hostContext, services) => | .ConfigureServices((hostContext, services) => | ||||
{ | { | ||||
services.AddControllers(); | services.AddControllers(); | ||||
services.AddCors(options => | services.AddCors(options => | ||||
options.AddPolicy("Domain", builder => | options.AddPolicy("Domain", builder => | ||||
@@ -46,6 +50,7 @@ namespace JT808.Gateway.CleintBenchmark | |||||
.AllowAnyMethod() | .AllowAnyMethod() | ||||
.AllowAnyHeader() | .AllowAnyHeader() | ||||
.AllowAnyOrigin())); | .AllowAnyOrigin())); | ||||
services.AddSignalR(); | |||||
}); | }); | ||||
}) | }) | ||||
@@ -71,6 +76,7 @@ namespace JT808.Gateway.CleintBenchmark | |||||
.AddClient() | .AddClient() | ||||
.AddClientReport(); | .AddClientReport(); | ||||
services.AddHostedService<CleintBenchmarkHostedService>(); | services.AddHostedService<CleintBenchmarkHostedService>(); | ||||
services.AddHostedService<QueryReportHostedService>(); | |||||
}); | }); | ||||
await serverHostBuilder.RunConsoleAsync(); | await serverHostBuilder.RunConsoleAsync(); | ||||
} | } | ||||
@@ -58,17 +58,20 @@ namespace JT808.Gateway.CleintBenchmark.Services | |||||
{ | { | ||||
int lat = new Random(1000).Next(100000, 180000); | int lat = new Random(1000).Next(100000, 180000); | ||||
int Lng = 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) | catch (Exception ex) | ||||
{ | { | ||||
@@ -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); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -4,9 +4,10 @@ | |||||
<head> | <head> | ||||
<meta charset="utf-8" /> | <meta charset="utf-8" /> | ||||
<title>收发查看</title> | <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="/echarts.min.js"></script> | ||||
<script src="/signalr.min.js"></script> | |||||
</head> | </head> | ||||
<body> | <body> | ||||
@@ -96,51 +97,98 @@ | |||||
data: offlineData | 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") { | if (tcpOption && typeof tcpOption === "object") { | ||||
tcpChart.setOption(tcpOption, true); | tcpChart.setOption(tcpOption, true); | ||||
} | } | ||||
@@ -47,7 +47,7 @@ namespace JT808.Gateway.Kafka | |||||
public static IJT808ClientBuilder AddMsgReplyConsumer(this IJT808ClientBuilder jT808ClientBuilder, IConfiguration configuration) | public static IJT808ClientBuilder AddMsgReplyConsumer(this IJT808ClientBuilder jT808ClientBuilder, IConfiguration configuration) | ||||
{ | { | ||||
jT808ClientBuilder.JT808Builder.Services.Configure<JT808MsgReplyConsumerConfig>(configuration.GetSection("JT808MsgReplyConsumerConfig")); | 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; | return jT808ClientBuilder; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -59,8 +59,7 @@ namespace JT808.Gateway.NormalHosting | |||||
.AddTransmit(hostContext.Configuration) | .AddTransmit(hostContext.Configuration) | ||||
.AddTcp() | .AddTcp() | ||||
.AddUdp() | .AddUdp() | ||||
.AddHttp() | |||||
.Register();//必须注册的 | |||||
.AddHttp(); | |||||
services.AddJT808WebApiClientTool(hostContext.Configuration); | services.AddJT808WebApiClientTool(hostContext.Configuration); | ||||
//httpclient客户端调用 | //httpclient客户端调用 | ||||
services.AddHostedService<CallHttpClientJob>(); | services.AddHostedService<CallHttpClientJob>(); | ||||
@@ -62,8 +62,7 @@ namespace JT808.Gateway.QueueHosting | |||||
.AddServerKafkaMsgReplyConsumer(hostContext.Configuration) | .AddServerKafkaMsgReplyConsumer(hostContext.Configuration) | ||||
.AddTcp() | .AddTcp() | ||||
.AddUdp() | .AddUdp() | ||||
.AddHttp() | |||||
.Register();//必须注册的 | |||||
.AddHttp(); | |||||
services.AddJT808WebApiClientTool(hostContext.Configuration); | services.AddJT808WebApiClientTool(hostContext.Configuration); | ||||
//httpclient客户端调用 | //httpclient客户端调用 | ||||
services.AddHostedService<CallHttpClientJob>(); | services.AddHostedService<CallHttpClientJob>(); | ||||
@@ -151,14 +151,14 @@ namespace JT808.Gateway.Test.Session | |||||
[Fact] | [Fact] | ||||
public void SendTest() | public void SendTest() | ||||
{ | { | ||||
Assert.Throws<SocketException>(() => | |||||
Assert.ThrowsAsync<SocketException>(async () => | |||||
{ | { | ||||
string tno = "123456"; | string tno = "123456"; | ||||
JT808SessionManager jT808SessionManager = new JT808SessionManager(new LoggerFactory()); | JT808SessionManager jT808SessionManager = new JT808SessionManager(new LoggerFactory()); | ||||
var session = new JT808TcpSession(new Socket(SocketType.Stream, ProtocolType.Tcp)); | var session = new JT808TcpSession(new Socket(SocketType.Stream, ProtocolType.Tcp)); | ||||
var result1 = jT808SessionManager.TryAdd(session); | var result1 = jT808SessionManager.TryAdd(session); | ||||
jT808SessionManager.TryLink(tno, 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 }); | |||||
}); | }); | ||||
} | } | ||||
@@ -29,14 +29,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.QueueHosting" | |||||
EndProject | EndProject | ||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmark", "Benchmark", "{6FAEC008-93CB-4730-8C58-D31FFD342C4F}" | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmark", "Benchmark", "{6FAEC008-93CB-4730-8C58-D31FFD342C4F}" | ||||
EndProject | 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}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.WebApiClientTool", "JT808.Gateway.WebApiClientTool\JT808.Gateway.WebApiClientTool.csproj", "{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}" | ||||
EndProject | 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}" | 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 | 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 | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|Any CPU = Debug|Any CPU | 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}.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.ActiveCfg = Release|Any CPU | ||||
{52D895BD-C60B-42D8-9229-C85927546FDA}.Release|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU | ||||
{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Debug|Any CPU.Build.0 = 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 | {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}.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.ActiveCfg = Release|Any CPU | ||||
{886D0A3F-C974-442B-9820-F1C4C04EAAB6}.Release|Any CPU.Build.0 = 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 | EndGlobalSection | ||||
GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||
@@ -110,9 +110,9 @@ Global | |||||
{E3DC260E-0B55-4993-B051-402E44D4E883} = {7CBAACEE-19BF-499A-8C41-36A1324D45E9} | {E3DC260E-0B55-4993-B051-402E44D4E883} = {7CBAACEE-19BF-499A-8C41-36A1324D45E9} | ||||
{22368AAD-A1F3-446B-B68F-98A0933BF1F6} = {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} | {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} | {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 | EndGlobalSection | ||||
GlobalSection(ExtensibilityGlobals) = postSolution | GlobalSection(ExtensibilityGlobals) = postSolution | ||||
SolutionGuid = {AA9303A7-6FB3-4572-88AA-3302E85330D1} | SolutionGuid = {AA9303A7-6FB3-4572-88AA-3302E85330D1} | ||||
@@ -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() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -143,12 +143,6 @@ | |||||
<param name="config"></param> | <param name="config"></param> | ||||
<returns></returns> | <returns></returns> | ||||
</member> | </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)"> | <member name="M:JT808.Gateway.JT808GatewayExtensions.AddJT808Core(JT808.Gateway.Abstractions.IJT808GatewayBuilder)"> | ||||
<summary> | <summary> | ||||
添加公共模块 | 添加公共模块 | ||||
@@ -150,21 +150,10 @@ namespace JT808.Gateway | |||||
public static IJT808GatewayBuilder AddMsgReplyConsumer<TJT808MsgReplyConsumer>(this IJT808GatewayBuilder config) | public static IJT808GatewayBuilder AddMsgReplyConsumer<TJT808MsgReplyConsumer>(this IJT808GatewayBuilder config) | ||||
where TJT808MsgReplyConsumer : IJT808MsgReplyConsumer | 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; | return config; | ||||
} | } | ||||
/// <summary> | /// <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> | /// </summary> | ||||
/// <param name="config"></param> | /// <param name="config"></param> | ||||
@@ -175,6 +164,8 @@ namespace JT808.Gateway | |||||
config.JT808Builder.Services.AddSingleton<JT808SessionManager>(); | config.JT808Builder.Services.AddSingleton<JT808SessionManager>(); | ||||
config.JT808Builder.Services.AddSingleton<IJT808MsgProducer, JT808MsgProducer_Empty>(); | config.JT808Builder.Services.AddSingleton<IJT808MsgProducer, JT808MsgProducer_Empty>(); | ||||
config.JT808Builder.Services.AddSingleton<IJT808MsgReplyLoggingProducer, JT808MsgReplyLoggingProducer_Empty>(); | config.JT808Builder.Services.AddSingleton<IJT808MsgReplyLoggingProducer, JT808MsgReplyLoggingProducer_Empty>(); | ||||
config.JT808Builder.Services.AddSingleton<IJT808MsgReplyConsumer, JT808MsgReplyConsumer_Empry>(); | |||||
config.JT808Builder.Services.AddHostedService<JT808MsgReplyHostedService>(); | |||||
return config; | return config; | ||||
} | } | ||||
} | } |