public TermianlConsumer(IConfiguration configuration, IServiceProvider serviceProvider) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _client = new SkynetTerminalClient(configuration["EventBusConnection"], configuration["EventBusConnection"]); _client.MessageCallBack += Client_MessageCallBack; _client.Subscribe($"#.SkynetTerminal.{SkynetTerminalCmdEnum.DeviceAlarm}"); _client.Subscribe($"#.SkynetTerminal.{SkynetTerminalCmdEnum.ChannelStatus}"); }
public static IServiceCollection AddTerminal(this IServiceCollection services, IConfiguration configuration) { var terminal = new SkynetTerminalClient( new Common.MsgServerInfo { HostIP = configuration["EventBusConnection"] ?? "127.0.0.1", Password = configuration["EventBusPassword"] ?? "123456", UserName = configuration["EventBusUserName"] ?? "sfbr" }, new Common.MsgServerInfo { HostIP = configuration["EventBusConnection"] ?? "127.0.0.1", Password = configuration["EventBusPassword"] ?? "123456", UserName = configuration["EventBusUserName"] ?? "sfbr" }); return(services.AddSingleton <ISkynetTerminalClient>(terminal)); }
public TerminalConsumer(IConfiguration configuration, IServiceProvider serviceProvider) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); //_client = new SkynetTerminalClient(new MsgServerInfo() { HostIP = "192.168.0.251", UserName = "******", Password = "******" }, new MsgServerInfo() { HostIP = "192.168.0.251", UserName = "******", Password = "******" }); _client = new SkynetTerminalClient( new MsgServerInfo { HostIP = configuration["EventBusConnection"], Password = configuration["EventBusPassword"], UserName = configuration["EventBusUserName"] }, new MsgServerInfo { HostIP = configuration["EventBusConnection"], Password = configuration["EventBusPassword"], UserName = configuration["EventBusUserName"] }); _client.MessageCallBack += Client_MessageCallBack; _client.Subscribe("#.SkynetTerminal.*");//订阅所有消息 _mqttClient = serviceProvider.GetService <IMqttClient>(); }