You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
1.7 KiB

  1. using JT808.Gateway.Abstractions.Enums;
  2. using JT808.Protocol;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.DependencyInjection.Extensions;
  6. using Microsoft.Extensions.Hosting;
  7. using Microsoft.Extensions.Logging;
  8. using System;
  9. using System.Threading.Tasks;
  10. using JT808.Gateway.SimpleServer.Impl;
  11. using JT808.Gateway.SimpleServer.Services;
  12. using JT808.Gateway.Abstractions;
  13. using Microsoft.AspNetCore.Hosting;
  14. using JT808.Gateway.Abstractions.Configurations;
  15. using Microsoft.AspNetCore.Builder;
  16. using JT808.Gateway.Extensions;
  17. namespace JT808.Gateway.SimpleServer
  18. {
  19. class Program
  20. {
  21. static void Main(string[] args)
  22. {
  23. var builder = WebApplication.CreateBuilder(args);
  24. builder.Services.AddSingleton<ILoggerFactory, LoggerFactory>()
  25. .AddSingleton(typeof(ILogger<>), typeof(Logger<>))
  26. //使用内存队列实现会话通知
  27. .AddSingleton<JT808SessionService>()
  28. .AddSingleton<IJT808SessionProducer, JT808SessionProducer>()
  29. .AddSingleton<IJT808SessionConsumer, JT808SessionConsumer>()
  30. .AddJT808Configure()
  31. .AddGateway(builder.Configuration)
  32. .AddMessageHandler<JT808MessageHandlerImpl>()
  33. .AddMsgLogging<JT808MsgLogging>()
  34. .AddSessionNotice()
  35. .AddTransmit(builder.Configuration)
  36. .AddTcp()
  37. .AddUdp()
  38. .Builder();
  39. builder.Services.AddControllers();
  40. var app = builder.Build();
  41. app.UseRouting();
  42. app.MapControllers();
  43. app.Run();
  44. }
  45. }
  46. }