Exemplo n.º 1
0
        private void StreamListenerSuspended(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            fixtureOverview.ListenerOverview.IsSuspended = true;
            UpdateStateFromEventDetails(e);
        }
Exemplo n.º 2
0
        private void StreamListenerFlagsChanged(object sender, StreamListenerEventArgs streamListenerEventArgs)
        {
            var fixtureOverview = GetFixtureOverview(streamListenerEventArgs.Listener.FixtureId) as FixtureOverview;

            UpdateLastErrorResolved(streamListenerEventArgs, fixtureOverview);

            UpdateStateFromEventDetails(streamListenerEventArgs);
        }
Exemplo n.º 3
0
        private void StreamListenerBeginStreamUpdate(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            fixtureOverview.FeedUpdate = CreateFeedUpdate(e);

            UpdateStateFromEventDetails(e);
        }
Exemplo n.º 4
0
 private static void UpdateLastErrorResolved(StreamListenerEventArgs streamListenerEventArgs,
                                             FixtureOverview fixtureOverview)
 {
     if (fixtureOverview.LastError != null &&
         fixtureOverview.LastError.IsErrored &&
         !streamListenerEventArgs.Listener.IsErrored)
     {
         fixtureOverview.LastError.ResolvedAt = DateTime.UtcNow;
         fixtureOverview.LastError.IsErrored  = false;
     }
 }
Exemplo n.º 5
0
        private void StreamListenerSnapshot(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            //assumption
            fixtureOverview.ListenerOverview.IsSuspended = false;

            fixtureOverview.FeedUpdate = CreateFeedUpdate(e, true);

            UpdateStateFromEventDetails(e);

            SaveState();
        }
Exemplo n.º 6
0
        private FeedUpdateOverview CreateFeedUpdate(StreamListenerEventArgs streamListenerArgs, bool isSnapshot = false)
        {
            var feedUpdate = new FeedUpdateOverview
            {
                Issued                = DateTime.UtcNow,
                Sequence              = streamListenerArgs.CurrentSequence,
                IsSnapshot            = isSnapshot,
                Epoch                 = streamListenerArgs.Epoch,
                LastEpochChangeReason = streamListenerArgs.LastEpochChangeReason
            };

            return(feedUpdate);
        }
Exemplo n.º 7
0
        private void StreamListenerErrored(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            fixtureOverview.LastError = new ErrorOverview
            {
                ErroredAt = DateTime.UtcNow,
                Exception = e.Exception,
                IsErrored = e.Exception != null,
                Sequence  = e.CurrentSequence
            };

            UpdateStateFromEventDetails(e);
        }
Exemplo n.º 8
0
        private void StreamListenerFinishedProcessingUpdate(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            if (fixtureOverview.FeedUpdate != null && fixtureOverview.FeedUpdate.Sequence == e.CurrentSequence)
            {
                var feedUpdate = fixtureOverview.FeedUpdate.Clone() as FeedUpdateOverview;
                feedUpdate.IsProcessed     = true;
                feedUpdate.ProcessingTime  = DateTime.UtcNow - feedUpdate.Issued;
                fixtureOverview.FeedUpdate = feedUpdate;
            }

            UpdateLastErrorResolved(e, fixtureOverview);
            UpdateStateFromEventDetails(e);
        }
Exemplo n.º 9
0
        private void UpdateStateFromEventDetails(StreamListenerEventArgs streamListenerEventArgs)
        {
            UpdateStateFromStreamListener(streamListenerEventArgs.Listener as StreamListener);

            var fixtureOverview = GetFixtureOverview(streamListenerEventArgs.Listener.FixtureId) as FixtureOverview;

            fixtureOverview.ListenerOverview.Sequence              = streamListenerEventArgs.CurrentSequence;
            fixtureOverview.ListenerOverview.Epoch                 = streamListenerEventArgs.Epoch;
            fixtureOverview.ListenerOverview.StartTime             = streamListenerEventArgs.StartTime ?? fixtureOverview.ListenerOverview.StartTime;
            fixtureOverview.ListenerOverview.LastEpochChangeReason = streamListenerEventArgs.LastEpochChangeReason ?? fixtureOverview.ListenerOverview.LastEpochChangeReason;

            fixtureOverview.Name = streamListenerEventArgs.Name ?? fixtureOverview.Name;
            fixtureOverview.ListenerOverview.MatchStatus = streamListenerEventArgs.MatchStatus ?? fixtureOverview.ListenerOverview.MatchStatus;

            if (streamListenerEventArgs.IsSnapshot)
            {
                fixtureOverview.CompetitionId   = streamListenerEventArgs.CompetitionId;
                fixtureOverview.CompetitionName = streamListenerEventArgs.CompetitionName;
            }

            PublishDelta(fixtureOverview);

            UpdateSportDetails(streamListenerEventArgs.Listener.Sport);
        }
Exemplo n.º 10
0
 private static void UpdateLastErrorResolved(StreamListenerEventArgs streamListenerEventArgs,
     FixtureOverview fixtureOverview)
 {
     if (fixtureOverview.LastError != null
         && fixtureOverview.LastError.IsErrored
         && !streamListenerEventArgs.Listener.IsErrored)
     {
         fixtureOverview.LastError.ResolvedAt = DateTime.UtcNow;
         fixtureOverview.LastError.IsErrored = false;
     }
 }
Exemplo n.º 11
0
        private void StreamListenerErrored(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;
            fixtureOverview.LastError = new ErrorOverview
            {
                ErroredAt = DateTime.UtcNow,
                Exception = e.Exception,
                IsErrored = e.Exception != null,
                Sequence = e.CurrentSequence
            };

            UpdateStateFromEventDetails(e);
        }
Exemplo n.º 12
0
        private void StreamListenerSnapshot(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            //assumption
            fixtureOverview.ListenerOverview.IsSuspended = false;

            fixtureOverview.FeedUpdate = CreateFeedUpdate(e, true);

            UpdateStateFromEventDetails(e);

            SaveState();
        }
Exemplo n.º 13
0
        private void StreamListenerFlagsChanged(object sender, StreamListenerEventArgs streamListenerEventArgs)
        {
            var fixtureOverview = GetFixtureOverview(streamListenerEventArgs.Listener.FixtureId) as FixtureOverview;

            UpdateLastErrorResolved(streamListenerEventArgs, fixtureOverview);

            UpdateStateFromEventDetails(streamListenerEventArgs);
        }
Exemplo n.º 14
0
        private FeedUpdateOverview CreateFeedUpdate(StreamListenerEventArgs streamListenerArgs, bool isSnapshot = false)
        {
            var feedUpdate = new FeedUpdateOverview
            {
                Issued = DateTime.UtcNow,
                Sequence = streamListenerArgs.CurrentSequence,
                IsSnapshot = isSnapshot,
                Epoch = streamListenerArgs.Epoch,
                LastEpochChangeReason = streamListenerArgs.LastEpochChangeReason
            };

            return feedUpdate;
        }
Exemplo n.º 15
0
 private void StreamListenerSuspended(object sender, StreamListenerEventArgs e)
 {
     var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;
     fixtureOverview.ListenerOverview.IsSuspended = true;
     UpdateStateFromEventDetails(e);
 }
Exemplo n.º 16
0
        private void StreamListenerBeginStreamUpdate(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            fixtureOverview.FeedUpdate = CreateFeedUpdate(e);

            UpdateStateFromEventDetails(e);
        }
Exemplo n.º 17
0
 private void StreamListenerConnected(object sender, StreamListenerEventArgs e)
 {
     UpdateStateFromEventDetails(e);
 }
Exemplo n.º 18
0
 private void StreamListenerConnected(object sender, StreamListenerEventArgs e)
 {
     UpdateStateFromEventDetails(e);
 }
Exemplo n.º 19
0
        private void UpdateStateFromEventDetails(StreamListenerEventArgs streamListenerEventArgs)
        {
            UpdateStateFromStreamListener(streamListenerEventArgs.Listener as StreamListener);

            var fixtureOverview = GetFixtureOverview(streamListenerEventArgs.Listener.FixtureId) as FixtureOverview;
            fixtureOverview.ListenerOverview.Sequence = streamListenerEventArgs.CurrentSequence;
            fixtureOverview.ListenerOverview.Epoch = streamListenerEventArgs.Epoch;
            fixtureOverview.ListenerOverview.StartTime = streamListenerEventArgs.StartTime ?? fixtureOverview.ListenerOverview.StartTime;
            fixtureOverview.ListenerOverview.LastEpochChangeReason = streamListenerEventArgs.LastEpochChangeReason ?? fixtureOverview.ListenerOverview.LastEpochChangeReason;

            fixtureOverview.Name = streamListenerEventArgs.Name ?? fixtureOverview.Name;
            fixtureOverview.ListenerOverview.MatchStatus = streamListenerEventArgs.MatchStatus ?? fixtureOverview.ListenerOverview.MatchStatus;

            if (streamListenerEventArgs.IsSnapshot)
            {
                fixtureOverview.CompetitionId = streamListenerEventArgs.CompetitionId;
                fixtureOverview.CompetitionName = streamListenerEventArgs.CompetitionName;
            }
            
            PublishDelta(fixtureOverview);

            UpdateSportDetails(streamListenerEventArgs.Listener.Sport);
        }
Exemplo n.º 20
0
        private void StreamListenerFinishedProcessingUpdate(object sender, StreamListenerEventArgs e)
        {
            var fixtureOverview = GetFixtureOverview(e.Listener.FixtureId) as FixtureOverview;

            if (fixtureOverview.FeedUpdate != null && fixtureOverview.FeedUpdate.Sequence == e.CurrentSequence)
            {
                var feedUpdate = fixtureOverview.FeedUpdate.Clone() as FeedUpdateOverview;
                feedUpdate.IsProcessed = true;
                feedUpdate.ProcessingTime = DateTime.UtcNow - feedUpdate.Issued;
                fixtureOverview.FeedUpdate = feedUpdate;
            }

            UpdateLastErrorResolved(e, fixtureOverview);
            UpdateStateFromEventDetails(e);
        }