public async Task Start()
        {
            // if we restarted, reset the stats, as uptime and since will be out of sync with counts
            StartClock();

            try
            {
                await foreach (var line in GetSampleStream())
                {
                    // v2 continue instead
                    // twitter appears to send empty lines occassionally
                    if (line == string.Empty)
                    {
                        continue;
                    }

                    // want to parse at least id and text out
                    var tweetDTO = TwitterTweetDTO.Deserialize(line);
                    if (tweetDTO == null)
                    {
                        anyNullTweets = true;
                        continue;
                    }

                    var tweet = new Tweet(tweetDTO);
                    // v2 is it better if TweetStream knows how to track stats or if TweetStatistics does?
                    stats.Track(tweet);
                }
            }
            catch (Exception ex)
            {
                anyExceptions = true;
            }
        }
Exemple #2
0
        }                                                            // v2 remove?


        public Tweet(TwitterTweetDTO dto) : this(dto.Id, dto.Text, TweetMedia.From(dto.Includes?.Media))
        {
        }
Exemple #3
0
 public static Tweet From(TwitterTweetDTO dto)
 {
     return(new Tweet(dto.Text, dto.Id, TweetMedia.From(dto.Includes.Media)));
 }