Exemple #1
0
        public bool Update()
        {
            IsInitializing = true;
            _logger.Info("Updating vMix state.");
            var _temp = Create();

            if (_temp == null)
            {
                _logger.Info("vMix is offline");
                _logger.Info("Firing \"updated\" event.");

                OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                {
                    Successfully = false
                });
                IsInitializing = false;
                return(false);
            }

            _logger.Info("Calculating difference.");
            Diff(this, _temp);

            _logger.Info("Updating inputs.");

            Inputs.Clear();
            foreach (var item in _temp.Inputs)
            {
                Inputs.Add(item);
            }
            Overlays.Clear();
            foreach (var item in _temp.Overlays)
            {
                Overlays.Add(item);
            }


            UpdateChangedInputs(_currentStateText, _temp._currentStateText);
            if (_currentStateText != _temp._currentStateText)
            {
                _currentStateText = _temp._currentStateText;
            }

            _logger.Info("Firing \"updated\" event.");

            OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
            {
                Successfully = true, OldInputs = null, NewInputs = null
            });
            IsInitializing = false;
            return(true);
        }
Exemple #2
0
        public void UpdateAsync()
        {
            SendFunction("", true, x =>
            {
                var e = (DownloadStringCompletedEventArgs)x;

                if (e.Error != null)
                {
                    OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                    {
                        Successfully = false
                    });
                    return;
                }
                if (e.UserState == null)
                {
                    return;
                }
                IsInitializing = true;
                _logger.Info("Updating vMix state.");
                var _temp = Create(e.Result);

                if (_temp == null)
                {
                    _logger.Info("vMix is offline");
                    _logger.Info("Firing \"updated\" event.");

                    IsInitializing = false;
                    OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                    {
                        Successfully = false
                    });
                }

                _logger.Info("Calculating difference.");
                Diff(this, _temp);

                _logger.Info("Updating inputs.");

                Inputs.Clear();
                foreach (var item in _temp.Inputs)
                {
                    Inputs.Add(item);
                }
                Overlays.Clear();
                foreach (var item in _temp.Overlays)
                {
                    Overlays.Add(item);
                }

                /*_previousStateText = _currentStateText;
                 * _currentStateText = _temp.CurrentStateText;*/
                UpdateChangedInputs(_currentStateText, _temp._currentStateText);
                if (_currentStateText != _temp._currentStateText)
                {
                    _currentStateText = _temp._currentStateText;
                }

                _logger.Info("Firing \"updated\" event.");

                IsInitializing = false;
                OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                {
                    Successfully = true, OldInputs = null, NewInputs = null
                });
                return;
            });
        }
Exemple #3
0
        public void UpdateAsync()
        {
            SendFunction("", true, x =>
            {
                try
                {
                    var e = (DownloadStringCompletedEventArgs)x;

                    if (e.Error != null)
                    {
                        OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                        {
                            Successfully = false
                        });
                        return;
                    }
                    if (e.UserState == null)
                    {
                        return;
                    }
                    IsInitializing = true;
                    _logger.Debug("Updating vMix state.");
                    var _temp = Create(e.Result);

                    if (_temp == null)
                    {
                        _logger.Debug("vMix is offline");
                        _logger.Debug("Firing \"updated\" event.");

                        IsInitializing = false;
                        OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                        {
                            Successfully = false
                        });
                    }

                    _logger.Debug("Calculating difference.");
                    Diff(this, _temp);

                    _logger.Debug("Updating inputs.");
                    if (Inputs == null)
                    {
                        Inputs = new List <Input>();
                    }
                    if (Overlays == null)
                    {
                        Overlays = new List <Overlay>();
                    }
                    if (Audio == null)
                    {
                        Audio = new List <Master>();
                    }
                    if (Transitions == null)
                    {
                        Transitions = new List <Transition>();
                    }
                    Inputs.Clear();
                    foreach (var item in _temp.Inputs)
                    {
                        Inputs.Add(item);
                    }
                    Overlays.Clear();
                    foreach (var item in _temp.Overlays)
                    {
                        Overlays.Add(item);
                    }
                    Audio.Clear();
                    foreach (var item in _temp.Audio)
                    {
                        Audio.Add(item);
                    }
                    Transitions.Clear();
                    foreach (var item in _temp.Transitions)
                    {
                        Transitions.Add(item);
                    }
                    Mixes.Clear();
                    foreach (var item in _temp.Mixes)
                    {
                        Mixes.Add(item);
                    }


                    if (_currentStateText != _temp._currentStateText)
                    {
                        _currentStateText = _temp._currentStateText;
                    }

                    _logger.Debug("Firing \"updated\" event.");

                    IsInitializing = false;
                    OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                    {
                        Successfully = true, OldInputs = null, NewInputs = null
                    });
                    return;
                }
                catch (Exception e)
                {
                    IsInitializing = false;
                    _logger.Error(e, "Exception at UpdateAsync");
                }
            });
        }
Exemple #4
0
        public bool Update()
        {
            try
            {
                IsInitializing = true;
                _logger.Debug("Updating vMix state.");
                var _temp = Create();

                if (_temp == null)
                {
                    _logger.Debug("vMix is offline");
                    _logger.Debug("Firing \"updated\" event.");

                    OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                    {
                        Successfully = false
                    });
                    IsInitializing = false;
                    return(false);
                }

                _logger.Debug("Calculating difference.");
                Diff(this, _temp);

                _logger.Debug("Updating inputs.");

                Inputs.Clear();
                foreach (var item in _temp.Inputs)
                {
                    Inputs.Add(item);
                }
                Overlays.Clear();
                foreach (var item in _temp.Overlays)
                {
                    Overlays.Add(item);
                }
                Audio.Clear();
                foreach (var item in _temp.Audio)
                {
                    Audio.Add(item);
                }
                Transitions.Clear();
                foreach (var item in _temp.Transitions)
                {
                    Transitions.Add(item);
                }
                Mixes.Clear();
                foreach (var item in _temp.Mixes)
                {
                    Mixes.Add(item);
                }

                //UpdateChangedInputs(_currentStateText, _temp._currentStateText);
                if (_currentStateText != _temp._currentStateText)
                {
                    _currentStateText = _temp._currentStateText;
                }

                _logger.Debug("Firing \"updated\" event.");

                OnStateSynced?.Invoke(this, new StateSyncedEventArgs()
                {
                    Successfully = true, OldInputs = null, NewInputs = null
                });
                IsInitializing = false;
                return(true);
            }
            catch (Exception e)
            {
                IsInitializing = false;
                _logger.Error(e, "Exception at Update");
                return(false);
            }
        }