public TwitterConnection()
        {
            _context = GlobalHost.ConnectionManager.GetHubContext <TwitterHub>();
            var config = new StreamConfig()
            {
                ConsumerKey    = _consumerKey,
                ConsumerSecret = _consumerSecret,
                AccessToken    = _accessKey,
                AccessSecret   = _accessToken,
            };
            var stream = new TwitterStreamClient(config);

            // Subscribe to the tweet received event
            stream.TweetReceivedEvent += (sender, args) =>
            {
                // Broadcast the tweet to the client-side
                _context.Clients.All.broadcast(args.Tweet);
            };

            var sentimentAnalyser = new SentimentApi(stream);

            sentimentAnalyser.BatchProcessedEvent += (sender, args) =>
            {
                _context.Clients.All.processedBatch(args.Tweets);
            };

            stream.Start();
        }
 public SentimentApi(TwitterStreamClient stream)
 {
     stream.TweetReceivedEvent += (sender, args) =>
     {
         if (_tweets.Count < _batchSize)
         {
             _tweets.Add(args.Tweet);
         }
         else
         {
             GetSentiments(new List <Tweet>(_tweets));
             _tweets.Clear();
         }
     };
 }