Ejemplo n.º 1
0
 public SampleStreamProcessor(IConfiguration configuration,
                              ITweetRepository tweetRepository,
                              ICacheRepository cacheRepository,
                              ILogger <SampleStreamProcessor> logger,
                              IEmojiProcessor emojiProcessor,
                              IHashtagProcessor hashtagProcessor)
 {
     Logger                    = logger;
     EmojiProcessor            = emojiProcessor;
     HashtagProcessor          = hashtagProcessor;
     TweetRepository           = tweetRepository;
     CacheRepository           = cacheRepository;
     Configuration             = configuration;
     TwitterCredentialsOptions = configuration.GetSection(TwitterCredentialsOptions.TwitterCredentials).Get <TwitterCredentialsOptions>();
     SampleStreamOptions       = configuration.GetSection(SampleStreamOptions.SampleStream).Get <SampleStreamOptions>();
     UserClient                = new TwitterClient(TwitterCredentialsOptions.ConsumerKey, TwitterCredentialsOptions.ConsumerSecret, TwitterCredentialsOptions.AccessToken, TwitterCredentialsOptions.AccessSecret);
     SampleStream              = UserClient.Streams.CreateSampleStream();
     SampleStream.AddLanguageFilter(SampleStreamOptions.LanguageFilter);
     SampleStream.FilterLevel    = (StreamFilterLevel)SampleStreamOptions.FilterLevel;
     SampleStream.TweetReceived += (sender, eventArgs) =>
     {
         Tweets.Add((Tweet)eventArgs.Tweet);
         if (NumberOfTotalTweetsPerSession > SampleStreamOptions.MaxAllowedTweetsLimit)
         {
             StopStream();
         }
         if (Tweets.Count > SampleStreamOptions.TweetsPageSize || GetStreamStateAsync().Result == StreamStateEnum.Stop)
         {
             ProcessTweetsAsync();
         }
     };
 }
Ejemplo n.º 2
0
 private void InvalidateProcessors()
 {
     _hashtagProcessor    = new HashtagProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _locationProcessor   = new LocationProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _collectionProcessor = new CollectionProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _mediaProcessor      = new MediaProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _userProcessor       = new UserProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _storyProcessor      = new StoryProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _commentProcessor    = new CommentProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _profileProcessor    = new UserProfileProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _messagingProcessor  = new MessagingProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
     _feedProcessor       = new FeedProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger);
 }