BoxKite.Twitter.TwitterConnection.StartUserStreaming C# (CSharp) Метод

StartUserStreaming() публичный Метод

Start UserStreaming
public StartUserStreaming ( ) : void
Результат void
        public void StartUserStreaming()
        {
            UserStream = UserSession.UserStreamBuilder();

            // Separate stream events start 
            ConnectStreamEvents();

            ConnectUserStreams();
           
            // MORE MAGIC HAPPENS HERE
            // The Userstreams only get tweets/direct messages from the point the connection is opened. 
            // Historical tweets/direct messages have to be gathered using the traditional paging/cursoring APIs
            // (Request/Response REST).
            // but the higher level client doesnt want to worry about all that complexity.
            // in the BackfillPump, we gather these tweets/direct messages and pump them into the correct Observable
            Task.Factory.StartNew(ProcessBackfillPump);

            // If the UserStream disconnects, the userStreamConnected will fire & we'll reconnect
            // TODO if stream connection doesnt connect, fail over to UserStream.UserStreamActive.Where(status => status.IsFalse()).Subscribe(StartPollingUpdates);
            // TODO if cancellation requested externally, dont reconnect

            UserStream.StreamActive.Where(status => status == StreamSignal.Stopped).Subscribe(_ =>
            {
                UserStream.Start();
            });
        }

Usage Example

        private static void GetTweets(TwitterCredentials twittercredentials)
        {
            if (twittercredentials != null)
            {
                TwitterConnection = new TwitterConnection(twittercredentials);

                TwitterConnection.StartUserStreaming();

                ConsoleOutput.PrintMessage(TwitterConnection.TwitterCredentials.ScreenName +" is authorised to use BoxKite.Twitter.");

                var usersession = TwitterConnection.UserSession;
                var userstream = TwitterConnection.UserStream;
                var applicationsession = TwitterConnection.ApplicationSession;

                new List<Tweet>();

                var searchstream = usersession.StartSearchStream(track: "Intel");
                searchstream.FoundTweets.Subscribe(ProcessTweet);
                searchstream.Start();

                Thread.Sleep(TimeSpan.FromMinutes(120));
                searchstream.CancelStream.Cancel();
                searchstream.Stop();
            }
        }