示例#1
0
        private void PlayScenario(ReplayFeed replayFeed)
        {
            replayFeed.ReplayManager.StartReplayScenario(1, 10, 1000);
            Thread.Sleep(1000);
            var queueEvents = replayFeed.ReplayManager.GetEventsInQueue();

            _log.Info($"Currently {queueEvents.Count()} items in queue.");
        }
示例#2
0
        private IEnumerable <URN> SelectEventsFromSportDataProvider(ReplayFeed replayFeed)
        {
            // we can only add matches older then 48 hours
            var events = replayFeed.SportDataProvider.GetSportEventsByDateAsync(DateTime.Now.AddDays(-5)).Result.ToList();

            if (events.Count > 10)
            {
                for (var i = 0; i < 10; i++)
                {
                    yield return(events[i].Id);
                }
            }
        }
示例#3
0
        public void Run(MessageInterest messageInterest)
        {
            _log.Info("Running the OddsFeed SDK Replay Server example");

            _log.Info("Retrieving configuration from application configuration file");
            var configuration = Feed.GetConfigurationBuilder().SetAccessTokenFromConfigFile().SelectReplay().LoadFromConfigFile().Build();

            //you can also create the IOddsFeedConfiguration instance by providing required values
            //var configuration = Feed.CreateConfiguration("myAccessToken", new[] {"en"});

            _log.Info("Creating Feed instance");
            var replayFeed = new ReplayFeed(configuration);

            _log.Info("Creating IOddsFeedSession");
            var session = replayFeed.CreateBuilder()
                          .SetMessageInterest(messageInterest)
                          .Build();

            _log.Info("Attaching to feed events");
            AttachToFeedEvents(replayFeed);
            AttachToSessionEvents(session);

            _log.Info("Opening the feed instance");
            replayFeed.Open();

            ReplayServerInteraction(replayFeed);

            _log.Info("Example successfully started. Hit <enter> to quit");
            Console.WriteLine(string.Empty);
            Console.ReadLine();

            _log.Info("Stopping replay");
            replayFeed.ReplayManager.StopReplay();

            _log.Info("Closing / disposing the feed");
            replayFeed.Close();

            DetachFromFeedEvents(replayFeed);
            DetachFromSessionEvents(session);

            _log.Info("Stopped");
        }
示例#4
0
        private void PlayMatches(ReplayFeed replayFeed)
        {
            // option 1:
            // add events from sport data provider
            //foreach (var urn in SelectEventsFromSportDataProvider(replayFeed))
            //    WriteReplayResponse(replayFeed.ReplayManager.AddMessagesToReplayQueue(urn));

            // option 2:
            // add example events
            foreach (var urn in SelectExampleEvents())
            {
                WriteReplayResponse(replayFeed.ReplayManager.AddMessagesToReplayQueue(urn));
            }

            var queueEvents = replayFeed.ReplayManager.GetEventsInQueue();

            _log.Info($"Currently {queueEvents.Count()} items in queue.");

            WriteReplayResponse(replayFeed.ReplayManager.StartReplay(10, 1000));
        }
示例#5
0
        private void ReplayServerInteraction(ReplayFeed replayFeed)
        {
            WriteReplayResponse(replayFeed.ReplayManager.StopAndClearReplay());
            var replayStatus = replayFeed.ReplayManager.GetStatusOfReplay();

            WriteReplayStatus(replayStatus);
            var queueEvents = replayFeed.ReplayManager.GetEventsInQueue();

            _log.Info($"Currently {queueEvents.Count()} items in queue.");

            // there are two options:
            // play specific scenario or add specific matches to be replayed

            // option 1:
            PlayScenario(replayFeed);

            // option 2:
            //PlayMatches(replayFeed);

            replayStatus = replayFeed.ReplayManager.GetStatusOfReplay();
            WriteReplayStatus(replayStatus);
        }