Ejemplo n.º 1
0
        public void Start()
        {
            RegisterEventHandlers();

            Console.WriteLine("Starting Stream");
            _startOn = DateTime.Now;
            _stream.StartStream();
            Console.WriteLine("Stopped Streaming");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Producer. Streams tweets from twiter sample stream and post for consumer to process.
        /// </summary>
        /// <param name="target"></param>
        public void Produce(ITargetBlock <ITweet> target)
        {
            // Create Twitter sample stream (1% of all public tweets)
            _Stream = Stream.CreateSampleStream();

            _Stream.TweetReceived += (object sender, Tweetinvi.Events.TweetReceivedEventArgs e) => {
                target.Post(e.Tweet);
            };

            _Stream.AddTweetLanguageFilter(LanguageFilter.English);

            // Begin streaming from twitter sample stream
            _Stream.StartStream();

            // Set the target to the completed state to signal to the consumer
            // that no more data will be available
            target.Complete();
        }
Ejemplo n.º 3
0
        public void createSampleStreamForBloombergFilter()
        {
            bloombergTupels = new ConcurrentBag <Tupel>();
            IAuthenticatedUser user = setAuthentication();

            stream = Stream.CreateSampleStream();
            Filter <string> bloomfilter = new Filter <string>(10000);

            bloomfilter.Add("United Stats");
            bloomfilter.Add("Italy");
            bloomfilter.Add("Trump");
            bloomfilter.Add("Hillary");
            bloomfilter.Add("Holiday");
            bloomfilter.Add("Beach");
            bloomfilter.Add("Election");
            bloomfilter.Add("trump");
            bloomfilter.Add("hillary");
            bloomfilter.Add("holiday");
            bloomfilter.Add("eeach");
            bloomfilter.Add("election");
            stream.TweetReceived += (sender, args) =>
            {
                bloombergTweets++;
                if (args.Tweet.Hashtags.Count > 0)
                {
                    bloombergTweetsWithPlace++;
                    //  if (bloomfilter.Contains(args.Tweet.Place.Country))
                    // {

                    foreach (IHashtagEntity hashtag in args.Tweet.Hashtags)
                    {
                        Console.WriteLine(hashtag.Text);
                        if (bloomfilter.Contains(hashtag.Text))
                        {
                            bloombergTupels.Add(new Tupel(args.Tweet.CreatedBy.Name, args.Tweet.CreatedAt.ToLongTimeString()));
                        }
                    }
                    //    }
                }
            };
            stream.StartStream();
        }
Ejemplo n.º 4
0
        public void createSampleStreamForSampling()
        {
            samplingTupels = new ConcurrentBag <Tupel>();
            IAuthenticatedUser user = setAuthentication();

            stream = Stream.CreateSampleStream();

            stream.TweetReceived += (sender, args) =>
            {
                samplingTweets++;
                if (args.Tweet.Place != null)
                {
                    samplingTweetsWithPlace++;
                    if (hashString(args.Tweet.Place.Name) % 10 == 0)
                    {
                        samplingTupels.Add(new Tupel(args.Tweet.CreatedBy.Name, args.Tweet.CreatedAt.ToLongTimeString()));
                    }
                }
            };
            stream.StartStream();
        }
Ejemplo n.º 5
0
        public void createSampleStream()
        {
            Auth.SetUserCredentials("HK6dYDYaZ91hGHA7uQoi1oWIO",                          //Consumerkey
                                    "8uMf9m1UTx2ST9bhzd0Ow9BLhLmqrU2GLRdnU2seWSYTKm2trH", //Consumer Secret
                                    "793479816209174528-eqb2G4BCyhTb32KtNh1BnLdArWcDgiU", //Access Token
                                    "oaO4hXOeWXhXuyxJYY2RkE7ffwrdh7N8W3CAmh93CVykw"       //Acces Token Secret
                                    );
            var user = User.GetAuthenticatedUser();

            stream = Stream.CreateSampleStream();

            stream.TweetReceived += (sender, args) =>
            {
                i++;
                if (args.Tweet.Hashtags.Count > 0)
                {
                    hashtags.Add(args.Tweet.Hashtags[0].Text);
                    //Console.WriteLine(args.Tweet.Hashtags[0].Text);
                }
            };
            stream.StartStream();
        }
Ejemplo n.º 6
0
 private async Task RunTwitter()
 {
     _sampleStream.StartStream();
 }
Ejemplo n.º 7
0
 private static void tStream_StreamStopped(object sender, StreamExceptionEventArgs e)
 {
     tStream.StartStream();
 }