当前位置: 首页>>代码示例>>C#>>正文


C# TwitterService.CancelStreaming方法代码示例

本文整理汇总了C#中TweetSharp.TwitterService.CancelStreaming方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.CancelStreaming方法的具体用法?C# TwitterService.CancelStreaming怎么用?C# TwitterService.CancelStreaming使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TweetSharp.TwitterService的用法示例。


在下文中一共展示了TwitterService.CancelStreaming方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            TwangManSays("********************************************");
            TwangManSays("*             HANG THE TWANG               *");
            TwangManSays("********************************************");
            CurrentGames = new Dictionary<long, TwitterThread>();
            tweetsToSend = new ConcurrentQueue<SendArgs>();

           
            TwitterSender = new Task(DoWork);
            TwitterSender.Start();

            _sendService = new TwitterService(Authentication.ConsumerKey, Authentication.ConsumerSecret);
            _sendService.AuthenticateWith(Authentication.AccessToken, Authentication.AccessTokenSecret);

            _service = new TwitterService(Authentication.ConsumerKey, Authentication.ConsumerSecret);
            _service.AuthenticateWith(Authentication.AccessToken, Authentication.AccessTokenSecret);

            TwitterListener = new Task(Listen);
            TwitterListener.Start();


            Console.ReadLine();
            _service.CancelStreaming();
        }
开发者ID:justasitsounds,项目名称:TwitterHangman,代码行数:25,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            string _consumerKey = "JXTOavtgUIN3ucDNRX3qsG5HM",
                _consumerSecret = "zf7szYPlnz4RG4utTsHnQRrreye4aNDoj8SNw6yiuklG9roDaj",
                _accessToken = "65598981-Hbx6HVVi1prAkW1MkzhBEw8oX2vNTti1UMK4BAAiS",
                _accessTokenSecret = "yuQWecLhU5GqBUgdhysiJm7hbBGLCnmTNEInZvu5xOiiF";
            var service1 = new TwitterService(_consumerKey, _consumerSecret);
            service1.AuthenticateWith(_accessToken, _accessTokenSecret);

            var block = new AutoResetEvent(false);
            TwitterStatus[] searchResult = new TwitterStatus[0];

            service1.Search(new SearchOptions() { Q = ":)", Count = 20, IncludeEntities = true, Lang = "en" }, (result, respone) =>
            {
                Console.WriteLine("On going...");
                HttpStatusCode code = respone.StatusCode;

                if (code == HttpStatusCode.OK)
                {
                    searchResult = new TwitterStatus[result.Statuses.Count()];
                    result.Statuses.ToList().CopyTo(searchResult);
                    block.Set();
                }
            });

            //TwitterRateLimitStatus rate = service1.Response.RateLimitStatus;
            //Console.WriteLine("You have used " + rate.RemainingHits + " out of your " + rate.HourlyLimit);

            Console.WriteLine("Out going...");
            block.WaitOne();
            service1.CancelStreaming();
            if (searchResult.Count() > 0)
            {
                WebClient webClient = new WebClient();
                StreamWriter writer = new StreamWriter("out.txt");
                for (int i = 0; i < searchResult.Count(); i++){
                    var photo = searchResult[i].Entities.Media.FirstOrDefault(m => m.MediaType == TwitterMediaType.Photo);
                    string attachedPhoto = "-";
                    if (photo != null)
                    {
                        attachedPhoto = "O";
                        webClient.DownloadFile(photo.MediaUrl, searchResult[i].Id + ".jpg");
                    }
                    string s = searchResult[i].Id + "\t" + attachedPhoto + "\t" + searchResult[i].User.ScreenName + "\t" + searchResult[i].Text;
                    writer.WriteLine(s);
                }
                writer.Close();
            }
            Console.WriteLine("Finish");
        }
开发者ID:huynq9,项目名称:MS_TwitterSentimentAnalysis,代码行数:50,代码来源:GetTweetData.cs

示例3: ListenOnUserStream

        public static void ListenOnUserStream(TwitterService service)
        {
            service.AuthenticateWith(accessToken, accessTokenSecret);

            Console.WriteLine("Starting Listen");

            service.StreamUser((streamEvent, response) =>
            {
                Console.WriteLine(streamEvent.RawSource);
            });

            Console.ReadLine();

            service.CancelStreaming();
            Console.WriteLine("Ending Listen");
        }
开发者ID:mikehadlow,项目名称:socsnap,代码行数:16,代码来源:Main.cs

示例4: CanGetUserStream

        public void CanGetUserStream()
        {
            var service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);

            var block = new AutoResetEvent(false);

            Console.WriteLine("About to start listening on stream");

            Task.Factory.StartNew(() => block.Set());

            //			service.StreamUser((streamEvent, response) =>
            //            {
            //				Console.WriteLine(streamEvent.RawSource);
            //				block.Set();
            //			});

            Console.WriteLine("Waiting for events");
            block.WaitOne();

            service.CancelStreaming();
        }
开发者ID:mikehadlow,项目名称:socsnap,代码行数:22,代码来源:TweetSharpSpike.cs


注:本文中的TweetSharp.TwitterService.CancelStreaming方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。