本文整理汇总了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();
}
示例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");
}
示例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");
}
示例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();
}