Example #1
0
        OnlineStatusChange RefreshStatus()
        {
            var newState = Status;

            if (!OnlineLast.HasValue && !OfflineSince.HasValue)
            {
                newState = OnlineStatusOnline.Unknown;
            }
            else if (OnlineLast.HasValue && !OfflineSince.HasValue || OnlineLast > OfflineSince)
            {
                newState = OnlineStatusOnline.Online;
            }
            else if (OfflineSince + DebounceInterval < DateTimeOffset.Now)
            {
                newState = OnlineStatusOnline.Offline;
            }

            if (Status == newState)
            {
                return(new OnlineStatusChange(false, Status, Status));
            }

            if (newState == OnlineStatusOnline.Offline)
            {
                OnlineLast = null;
            }
            else if (newState == OnlineStatusOnline.Online)
            {
                OfflineSince = null;
            }

            var change = new OnlineStatusChange(true, Status, newState);

            Status = newState;
            return(change);
        }
Example #2
0
 public ProcessDiscoveryChange(Device device, OnlineStatusChange change) : base(change.Changed, change.FromStatus, change.ToStatus)
 {
     Device = device;
 }