/// <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>
 /// <typeparam name="TSessionNoticeService">自定义会话通知服务</typeparam>
 /// <param name="jT808NormalGatewayBuilder"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddSessionNotice <TSessionNoticeService>(this IJT808GatewayBuilder jT808NormalGatewayBuilder)
     where TSessionNoticeService : JT808SessionNoticeService
 {
     jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton <JT808SessionNoticeService, TSessionNoticeService>();
     jT808NormalGatewayBuilder.JT808Builder.Services.AddHostedService <JT808SessionNoticeHostedService>();
     return(jT808NormalGatewayBuilder);
 }
 /// <summary>
 /// 添加http服务器
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddHttp(this IJT808GatewayBuilder config)
 {
     config.JT808Builder.Services.AddSingleton <IJT808Authorization, JT808AuthorizationDefault>();
     config.JT808Builder.Services.AddSingleton <JT808MsgIdDefaultWebApiHandler>();
     config.JT808Builder.Services.AddHostedService <JT808HttpServer>();
     return(config);
 }
 public static IJT808GatewayBuilder AddJT808GatewayUdpHost(this IJT808GatewayBuilder jT808NettyBuilder)
 {
     jT808NettyBuilder.JT808Builder.Services.TryAddSingleton <IJT808DatagramPacket, JT808DatagramPacketImpl>();
     jT808NettyBuilder.JT808Builder.Services.TryAddScoped <JT808UdpDecoder>();
     jT808NettyBuilder.JT808Builder.Services.TryAddScoped <JT808UdpServerHandler>();
     jT808NettyBuilder.JT808Builder.Services.AddHostedService <JT808UdpServerHost>();
     return(jT808NettyBuilder);
 }
 /// <summary>
 /// 添加公共模块
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 private static IJT808GatewayBuilder AddJT808Core(this IJT808GatewayBuilder config)
 {
     config.JT808Builder.Services.AddSingleton <JT808MessageHandler>();
     config.JT808Builder.Services.AddSingleton <JT808SessionManager>();
     config.JT808Builder.Services.AddSingleton <IJT808MsgProducer, JT808MsgProducer_Empty>();
     config.JT808Builder.Services.AddSingleton <IJT808MsgReplyLoggingProducer, JT808MsgReplyLoggingProducer_Empty>();
     return(config);
 }
 /// <summary>
 /// 添加http服务器
 /// </summary>
 /// <typeparam name="TJT808MsgIdDefaultWebApiHandler"></typeparam>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddHttp <TJT808MsgIdDefaultWebApiHandler>(this IJT808GatewayBuilder config)
     where TJT808MsgIdDefaultWebApiHandler : JT808MsgIdDefaultWebApiHandler
 {
     config.JT808Builder.Services.AddSingleton <IJT808Authorization, JT808AuthorizationDefault>();
     config.JT808Builder.Services.AddSingleton(typeof(JT808MsgIdDefaultWebApiHandler), typeof(TJT808MsgIdDefaultWebApiHandler));
     config.JT808Builder.Services.AddHostedService <JT808HttpServer>();
     return(config);
 }
示例#7
0
 public static IJT808GatewayBuilder AddJT808GatewayTcpHost(this IJT808GatewayBuilder jT808NettyBuilder)
 {
     jT808NettyBuilder.JT808Builder.Services.TryAddScoped <JT808TcpConnectionHandler>();
     jT808NettyBuilder.JT808Builder.Services.TryAddScoped <JT808TcpEncoder>();
     jT808NettyBuilder.JT808Builder.Services.TryAddScoped <JT808TcpDecoder>();
     jT808NettyBuilder.JT808Builder.Services.TryAddScoped <JT808TcpServerHandler>();
     jT808NettyBuilder.JT808Builder.Services.AddHostedService <JT808TcpServerHost>();
     return(jT808NettyBuilder);
 }
 private static IJT808GatewayBuilder AddJT808Core(this IJT808GatewayBuilder config)
 {
     config.JT808Builder.Services.TryAddSingleton <JT808AtomicCounterServiceFactory>();
     config.JT808Builder.Services.TryAddSingleton <IJT808MsgProducer, JT808MsgProducerDefault>();
     config.JT808Builder.Services.TryAddSingleton <IJT808MsgReplyConsumer, JT808MsgReplyConsumerDefault>();
     config.JT808Builder.Services.TryAddSingleton <JT808SessionManager>();
     config.JT808Builder.Services.TryAddSingleton <JT808MsgService>();
     config.JT808Builder.Services.AddHostedService <JT808MsgReplyHostedService>();
     return(config);
 }
示例#9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="jT808NettyBuilder"></param>
 /// <param name="configuration">GetSection("JT808SessionProducerConfig")</param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddJT808ServerKafkaSessionProducer(this IJT808GatewayBuilder jT808GatewayBuilder, IConfiguration configuration)
 {
     jT808GatewayBuilder.JT808Builder.Services.Configure <JT808SessionProducerConfig>(configuration.GetSection("JT808SessionProducerConfig"));
     jT808GatewayBuilder.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808SessionProducer), typeof(JT808SessionProducer), ServiceLifetime.Singleton));
     return(jT808GatewayBuilder);
 }
示例#10
0
 /// <summary>
 /// 消息流量统计服务(不同的消费者实例)
 /// </summary>
 /// <param name="jT808NormalGatewayBuilder"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddTraffic(this IJT808GatewayBuilder jT808NormalGatewayBuilder)
 {
     jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808Traffic), typeof(JT808TrafficDefault));
     return(jT808NormalGatewayBuilder);
 }
示例#11
0
 /// <summary>
 /// 消息流量统计服务(不同的消费者实例)
 /// </summary>
 /// <param name="jT808NormalGatewayBuilder"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddTraffic <TIJT808Traffic>(this IJT808GatewayBuilder jT808NormalGatewayBuilder)
     where TIJT808Traffic : IJT808Traffic
 {
     jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808Traffic), typeof(TIJT808Traffic));
     return(jT808NormalGatewayBuilder);
 }
 /// <summary>
 /// 添加udp服务器
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddUdp(this IJT808GatewayBuilder config)
 {
     config.JT808Builder.Services.AddHostedService <JT808UdpServer>();
     config.JT808Builder.Services.AddHostedService <JT808UdpReceiveTimeoutHostedService>();
     return(config);
 }
 /// <summary>
 /// 会话通知服务
 /// </summary>
 /// <param name="jT808GatewayBuilder"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddSessionNotice(this IJT808GatewayBuilder jT808GatewayBuilder)
 {
     jT808GatewayBuilder.JT808Builder.Services.AddSingleton <JT808SessionNoticeService>();
     jT808GatewayBuilder.JT808Builder.Services.AddHostedService <JT808SessionNoticeHostedService>();
     return(jT808GatewayBuilder);
 }
示例#14
0
 /// <summary>
 /// 转发服务(不同的消费者实例)
 /// </summary>
 /// <param name="jT808GatewayBuilder"></param>
 /// <param name="configuration"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddTransmit(this IJT808GatewayBuilder jT808GatewayBuilder, IConfiguration configuration)
 {
     jT808GatewayBuilder.JT808Builder.Services.Configure <RemoteServerOptions>(configuration.GetSection("RemoteServerOptions"));
     jT808GatewayBuilder.JT808Builder.Services.AddSingleton <JT808TransmitService>();
     return(jT808GatewayBuilder);
 }
 /// <summary>
 /// 添加消息应答消费者
 /// </summary>
 /// <typeparam name="TJT808MsgReplyConsumer"></typeparam>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddMsgReplyConsumer <TJT808MsgReplyConsumer>(this IJT808GatewayBuilder config)
     where TJT808MsgReplyConsumer : IJT808MsgReplyConsumer
 {
     config.JT808Builder.Services.Add(new ServiceDescriptor(typeof(IJT808MsgReplyConsumer), typeof(TJT808MsgReplyConsumer), ServiceLifetime.Singleton));
     return(config);
 }
 /// <summary>
 /// 添加Http服务认证机制
 /// </summary>
 /// <typeparam name="TJT808Authorization"></typeparam>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddHttpAuthorization <TJT808Authorization>(this IJT808GatewayBuilder config)
     where TJT808Authorization : IJT808Authorization
 {
     config.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808Authorization), typeof(TJT808Authorization), ServiceLifetime.Singleton));
     return(config);
 }
 /// <summary>
 /// 添加消息业务处理程序
 /// </summary>
 /// <typeparam name="TJT808MessageHandler"></typeparam>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IJT808GatewayBuilder AddMessageHandler <TJT808MessageHandler>(this IJT808GatewayBuilder config)
     where TJT808MessageHandler : JT808MessageHandler
 {
     config.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(JT808MessageHandler), typeof(TJT808MessageHandler), ServiceLifetime.Singleton));
     return(config);
 }
 private static IJT808GatewayBuilder AddJT808Core(this IJT808GatewayBuilder config)
 {
     config.JT808Builder.Services.TryAddSingleton <JT808AtomicCounterServiceFactory>();
     config.JT808Builder.Services.TryAddSingleton <JT808SessionManager>();
     return(config);
 }
 public static IJT808GatewayBuilder AddGrpc(this IJT808GatewayBuilder config)
 {
     config.JT808Builder.Services.AddHostedService <JT808GrpcServer>();
     return(config);
 }
 private static IJT808GatewayBuilder AddJT808Core(this IJT808GatewayBuilder config)
 {
     config.JT808Builder.Services.AddSingleton <JT808MessageHandler>();
     config.JT808Builder.Services.AddSingleton <JT808SessionManager>();
     return(config);
 }
 public static IJT808GatewayBuilder AddMsgLogging <TJT808MsgLogging>(this IJT808GatewayBuilder jT808NormalGatewayBuilder)
     where TJT808MsgLogging : IJT808MsgLogging
 {
     jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808MsgLogging), typeof(TJT808MsgLogging));
     return(jT808NormalGatewayBuilder);
 }