Ejemplo n.º 1
0
        async Task RevokeRetry(UserStreamer Streamer)
        {
            if (RevokeRetryUserID.ContainsKey(Streamer.Token.UserId))
            {
                await db.DeleteToken(Streamer.Token.UserId).ConfigureAwait(false);

                RevokeRetryUserID.TryRemove(Streamer.Token.UserId, out byte z);
                RemoveStreamer(Streamer);
            }
            else
            {
                RevokeRetryUserID.TryAdd(Streamer.Token.UserId, 0);
            }                                                               //次回もRevokeされてたら消えてもらう
        }
Ejemplo n.º 2
0
 bool Add(Tokens t)
 {
     if (t == null)
     {
         return(false);
     }
     if (Streamers.ContainsKey(t.UserId))
     {
         //Console.WriteLine("{0} {1}: Already running.", DateTime.Now, t.UserId);
         return(false);
     }
     else
     {
         //Console.WriteLine("{0} {1}: Assigned.", DateTime.Now, t.UserId);
         UserStreamer s = new UserStreamer(t);
         return(Streamers.TryAdd(t.UserId, s));
     }
 }
Ejemplo n.º 3
0
        public async ValueTask <int> Proceed()
        {
            Tokens[] tokens = await db.Selecttoken(DBHandler.SelectTokenMode.All);

            if (tokens.Length > 0)
            {
                Console.WriteLine("App: {0} Accounts to REST", tokens.Length);
            }
            ActionBlock <Tokens> RestProcess = new ActionBlock <Tokens>(async(t) =>
            {
                UserStreamer s = new UserStreamer(t);
                await s.RestFriend();
                await s.RestBlock();
                await s.RestMyTweet();
            }, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = config.crawl.RestTweetThreads,
                BoundedCapacity        = config.crawl.RestTweetThreads << 1
            });
            Stopwatch sw = Stopwatch.StartNew();

            foreach (Tokens t in tokens)
            {
                await RestProcess.SendAsync(t);

                if (sw.ElapsedMilliseconds > 60000)
                {
                    Counter.PrintReset();
                    GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; //これは毎回必要らしい
                    GC.Collect();
                    sw.Restart();
                }
            }
            RestProcess.Complete();
            await RestProcess.Completion;

            return(tokens.Length);
        }
Ejemplo n.º 4
0
 ///<summary>Revokeされた後の処理</summary>
 void RemoveStreamer(UserStreamer Streamer)
 {
     Streamer.Dispose();
     Streamers.TryRemove(Streamer.Token.UserId, out UserStreamer z);  //つまり死んだStreamerは除外される
     Console.WriteLine("{0}: Streamer removed", Streamer.Token.UserId);
 }