本文整理汇总了C#中LinqToTwitter.TwitterContext.AddSiteStreamUserAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterContext.AddSiteStreamUserAsync方法的具体用法?C# TwitterContext.AddSiteStreamUserAsync怎么用?C# TwitterContext.AddSiteStreamUserAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.TwitterContext
的用法示例。
在下文中一共展示了TwitterContext.AddSiteStreamUserAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoControlStreamAsync
static async Task DoControlStreamAsync(TwitterContext twitterCtx)
{
var evt = new ManualResetEventSlim(false);
string streamID = string.Empty;
Task.Run(async () =>
{
Console.WriteLine("\nStreamed Content: \n");
int count = 0;
var cancelTokenSrc = new CancellationTokenSource();
try
{
await
(from strm in twitterCtx.Streaming
where strm.Type == StreamingType.Site &&
strm.Follow == "15411837,16761255"
select strm)
.WithCancellation(cancelTokenSrc.Token)
.StartAsync(async strm =>
{
if (string.IsNullOrEmpty(strm.Content))
Console.WriteLine("Keep-Alive");
else
HandleStreamResponse(strm);
if (strm.EntityType == StreamEntityType.Control)
{
var control = strm.Entity as Control;
streamID = control.URL.Replace("/1.1/site/c/", "");
evt.Set();
}
if (count++ == 25)
cancelTokenSrc.Cancel();
});
}
catch (OperationCanceledException)
{
Console.WriteLine("Stream cancelled.");
}
});
evt.Wait();
Console.WriteLine("Follower Details:\n");
var ctrlStrmFollowers =
await
(from strm in twitterCtx.ControlStream
where strm.Type == ControlStreamType.Followers &&
strm.UserID == 15411837 &&
strm.StreamID == streamID
select strm)
.SingleOrDefaultAsync();
if (ctrlStrmFollowers != null)
{
ControlStreamFollow follow = ctrlStrmFollowers.Follow;
ControlStreamUser followUser = follow.User;
List<ulong> friends = follow.Friends;
Cursors cursors = follow.Cursors;
Console.WriteLine("User ID: " + followUser.UserID);
Console.WriteLine("User Name: " + followUser.Name);
Console.WriteLine("Can DM: " + followUser.DM);
friends.ForEach(friend => Console.WriteLine(friend));
Console.WriteLine("Prev Cursor: " + cursors.Previous);
Console.WriteLine("Next Cursor: " + cursors.Next);
Console.WriteLine("Info Details:\n");
}
var ctrlStrmInfo =
(from strm in twitterCtx.ControlStream
where strm.Type == ControlStreamType.Info &&
strm.StreamID == streamID
select strm)
.SingleOrDefault();
if (ctrlStrmInfo != null)
{
ControlStreamInfo infoUser = ctrlStrmInfo.Info;
ControlStreamUser user = infoUser.Users.First();
Console.WriteLine("User ID: " + user.UserID);
Console.WriteLine("User Name: " + user.Name);
Console.WriteLine("Can DM: " + user.DM);
Console.WriteLine("Delimited: " + infoUser.Delimited);
Console.WriteLine("Include Followings Acitity: " + infoUser.IncludeFollowingsActivity);
Console.WriteLine("Include User Changes: " + infoUser.IncludeUserChanges);
Console.WriteLine("Replies: " + infoUser.Replies);
Console.WriteLine("With: " + infoUser.With);
Console.WriteLine("\nInitial Stream Users: ");
await PrintUserInfoAsync(twitterCtx, streamID);
ControlStream csAdd = await twitterCtx.AddSiteStreamUserAsync(new List<ulong> { 16761255 }, streamID);
Console.WriteLine("Command Response: " + csAdd.CommandResponse);
Console.WriteLine("\nAfter Adding a User: ");
//.........这里部分代码省略.........