コード例 #1
0
        private static IObservable <uint> Frames(Auto.ISource autoSource, Mqtt.ISource mqttSource)
        {
            IObservable <uint>            autoFrames           = autoSource.Create().Publish().RefCount();
            IObservable <uint>            mqttFrames           = mqttSource.Create().Publish().RefCount();
            IConnectableObservable <uint> mqttFramesWithReplay = mqttFrames.Replay(1);

            var mqttFrameTimeout = mqttFrames
                                   .Timeout(TimeSpan.FromSeconds(10))
                                   .IgnoreElements()
                                   .Materialize()
                                   .Where(notification => notification.Kind == NotificationKind.OnError);

            var autoFramesUntilMqttFrames = autoFrames.TakeUntil(mqttFrames);
            var mqttFramesUntilTimeout    = mqttFramesWithReplay.TakeUntil(mqttFrameTimeout);

            return(Observable.Using(
                       () => mqttFramesWithReplay.Connect(),
                       _ => Observable.Defer(() => Observable.Concat(autoFramesUntilMqttFrames, mqttFramesUntilTimeout)).Repeat()
                       ));
        }
コード例 #2
0
 public Service(Auto.ISource autoSource, Mqtt.ISource mqttSource, IOptions <Configuration> configuration, ILogger <Service> logger)
 {
     _frames        = Frames(autoSource, mqttSource);
     _configuration = configuration;
     _logger        = logger;
 }