示例#1
0
 public OutcomesSnapshot(PlatformEvent @event, DateTime createdAt, PlatformEventState state, Outcome[] outcomes)
 {
     Event     = @event ?? throw new ArgumentNullException(nameof(@event));
     CreatedAt = createdAt;
     State     = state;
     Outcomes  = outcomes ?? throw new ArgumentNullException(nameof(outcomes));
 }
示例#2
0
        public ScraperActor(IPlatformEventScraper scraper, ScrapingOptions options)
        {
            _scraper        = scraper;
            _options        = options;
            _cancelScraping = new Cancelable(Context.System.Scheduler);

            Receive <ScrapPage>(_ => _scraper.ScrapPage().PipeTo(Self));

            Receive <LiveOddsUpdate>(update =>
            {
                Context.Parent.Forward(update);
            });

            Receive <OutcomesSnapshot>(update =>
            {
                var context = Context;

                Context.Parent.Forward(update);

                if (_eventState == PlatformEventState.Open && update.State == PlatformEventState.Live)
                {
                    _cancelScraping.Cancel(false);
                    _scraper.SubscribeToLive(u => {
                        context.Self.Tell(u);
                    });
                    _eventState = update.State;
                }
                else if (update.State == PlatformEventState.Ended)
                {
                    Context.Parent.Tell(new RecyclePage(_scraper.Page));
                    Context.Stop(Self);
                }
            });
        }