Example #1
0
        public void StartStream(string url)
        {
            Func <HttpWebRequest> generateWebRequest = delegate
            {
                return(_oAuthToken.GetQueryWebRequest(url, HttpMethod.GET));
            };

            Action <string> generateTweetDelegate = json =>
            {
                var tweet = _tweetFactory.GenerateTweetFromJson(json);
                if (tweet == null)
                {
                    TryInvokeGlobalStreamMessages(json);
                    return;
                }

                var detectedTracksAndActions = _streamTrackManager.GetMatchingTracksAndActions(tweet.Text);
                var detectedTracks           = detectedTracksAndActions.Select(x => x.Item1);
                if (detectedTracksAndActions.Any())
                {
                    this.Raise(MatchingTweetReceived, new MatchedTweetReceivedEventArgs(tweet, detectedTracks));
                }
            };

            _streamResultGenerator.StartStream(generateTweetDelegate, generateWebRequest);
        }
Example #2
0
        public void StartStream(string url)
        {
            Func <HttpWebRequest> generateWebRequest = delegate
            {
                return(_oAuthToken.GetQueryWebRequest(url, HttpMethod.GET));
            };

            Action <string> generateTweetDelegate = json =>
            {
                var tweet = _tweetFactory.GenerateTweetFromJson(json);
                if (tweet == null)
                {
                    TryInvokeGlobalStreamMessages(json);
                    return;
                }

                this.Raise(TweetReceived, new TweetReceivedEventArgs(tweet));
            };

            _streamResultGenerator.StartStream(generateTweetDelegate, generateWebRequest);
        }