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.
 
 
 

52 lines
1.8 KiB

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