public JT809SubordinateClient( IServiceProvider provider, ILoggerFactory loggerFactory, IJT809SubordinateLinkNotifyService subordinateLinkNotifyService, IJT809VerifyCodeGenerator verifyCodeGenerator) { this.serviceProvider = provider; this.loggerFactory = loggerFactory; this.verifyCodeGenerator = verifyCodeGenerator; this.logger = loggerFactory.CreateLogger <JT809SubordinateClient>(); this.subordinateLinkNotifyService = subordinateLinkNotifyService; group = new MultithreadEventLoopGroup(); bootstrap = new Bootstrap(); bootstrap.Group(group) .Channel <TcpSocketChannel>() .Option(ChannelOption.TcpNodelay, true) .Handler(new ActionChannelInitializer <ISocketChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; //下级平台1分钟发送心跳 //上级平台是3分钟没有发送就断开连接 using (var scope = serviceProvider.CreateScope()) { pipeline.AddLast("jt809SubClientBuffer", new DelimiterBasedFrameDecoder(int.MaxValue, Unpooled.CopiedBuffer(new byte[] { JT809Package.BEGINFLAG }), Unpooled.CopiedBuffer(new byte[] { JT809Package.ENDFLAG }))); pipeline.AddLast("jt809SubClientSystemIdleState", new IdleStateHandler(180, 60, 200)); pipeline.AddLast("jt809SubClientEncode", scope.ServiceProvider.GetRequiredService <JT809Encoder>()); pipeline.AddLast("jt809SubClientDecode", scope.ServiceProvider.GetRequiredService <JT809Decoder>()); pipeline.AddLast("jt809SubClientConnection", scope.ServiceProvider.GetRequiredService <JT809SubordinateClientConnectionHandler>()); pipeline.AddLast("jt809SubClientServer", scope.ServiceProvider.GetRequiredService <JT809SubordinateClientHandler>()); } })); }
/// <summary> /// 初始化消息处理业务 /// </summary> protected JT809SuperiorMsgIdReceiveHandlerBase( ILoggerFactory loggerFactory, IJT809SubordinateLoginService jT809SubordinateLoginService, IJT809VerifyCodeGenerator verifyCodeGenerator) { this.Logger = loggerFactory.CreateLogger <JT809SuperiorMsgIdReceiveHandlerBase>(); this.VerifyCodeGenerator = verifyCodeGenerator; this.SubordinateLoginService = jT809SubordinateLoginService; HandlerDict = new Dictionary <JT809BusinessType, Func <JT809Request, JT809Response> > { { JT809BusinessType.主链路登录请求消息, Msg0x1001 }, { JT809BusinessType.主链路注销请求消息, Msg0x1003 }, { JT809BusinessType.主链路连接保持请求消息, Msg0x1005 }, { JT809BusinessType.主链路断开通知消息, Msg0x1007 }, { JT809BusinessType.主链路动态信息交换消息, Msg0x1200 }, { JT809BusinessType.级平台主动关闭链路通知消息, Msg0x1008 }, { JT809BusinessType.从链路连接应答消息, Msg0x9002 }, { JT809BusinessType.从链路注销应答消息, Msg0x9004 }, { JT809BusinessType.从链路连接保持应答消息, Msg0x9006 }, }; SubHandlerDict = new Dictionary <JT809SubBusinessType, Func <JT809Request, JT809Response> > { { JT809SubBusinessType.车辆注册信息, Msg0x1200_0x1201 }, { JT809SubBusinessType.主动上报驾驶员身份信息, Msg0x1200_0x120C }, { JT809SubBusinessType.实时上传车辆定位信息, Msg0x1200_0x1202 }, { JT809SubBusinessType.车辆定位信息自动补报, Msg0x1200_0x1203 }, }; }
public JT809SuperiorMsgIdReceiveHandler( IOptions <JT809GpsOptions> jt809GpsAccessor, JT809_GpsPositio_Producer producer, ILoggerFactory loggerFactory, IJT809SubordinateLoginService jT809SubordinateLoginService, IJT809VerifyCodeGenerator verifyCodeGenerator) : base(loggerFactory, jT809SubordinateLoginService, verifyCodeGenerator) { this.producer = producer; this.gpsOptions = jt809GpsAccessor.Value; }
/// <summary> /// 初始化消息处理业务 /// </summary> protected JT809InferiorMsgIdReceiveHandlerBase( ILoggerFactory loggerFactory, IOptions <JT809Configuration> jT809ConfigurationAccessor, IJT809VerifyCodeGenerator verifyCodeGenerator, JT809SubordinateClient subordinateLinkClient) { this.Logger = loggerFactory.CreateLogger <JT809SuperiorMsgIdReceiveHandlerBase>(); HandlerDict = new Dictionary <JT809BusinessType, Func <JT809Request, JT809Response> > { //{JT809BusinessType.主链路登录请求消息, Msg0x1001}, { JT809BusinessType.主链路注销请求消息, Msg0x1003 }, { JT809BusinessType.主链路连接保持请求消息, Msg0x1005 }, { JT809BusinessType.主链路动态信息交换消息, Msg0x1200 }, { JT809BusinessType.从链路注销应答消息, Msg0x9004 }, }; SubHandlerDict = new Dictionary <JT809SubBusinessType, Func <JT809Request, JT809Response> > { //{JT809SubBusinessType.实时上传车辆定位信息, Msg0x1200_0x1202}, }; }
public JT809InferiorMsgIdReceiveDefaultHandler(ILoggerFactory loggerFactory, IOptions <JT809Configuration> jT809ConfigurationAccessor, IJT809VerifyCodeGenerator verifyCodeGenerator, JT809SubordinateClient subordinateLinkClient) : base(loggerFactory, jT809ConfigurationAccessor, verifyCodeGenerator, subordinateLinkClient) { }
public JT809SuperiorMsgIdReceiveDefaultHandler(ILoggerFactory loggerFactory, IJT809SubordinateLoginService jT809SubordinateLoginService, IJT809VerifyCodeGenerator verifyCodeGenerator) : base(loggerFactory, jT809SubordinateLoginService, verifyCodeGenerator) { }