示例#1
0
        void clientListCleaner()
        {
            var rnd = new HermitLib.Random();

            while (true)
            {
                //1min-5min
                Thread.Sleep(rnd.Next(1 * 60 * 1000, 5 * 60 * 1000));

                lock (lock_clientList) {
                    //time clips --
                    foreach (var item in handshakeList.Values)
                    {
                        item.TimeClips--;
                    }
                    foreach (var item in normalList.Values)
                    {
                        item.TimeClips--;
                    }
                    foreach (var item in rtrList)
                    {
                        item.TimeClips--;
                    }

                    //evaluate client
                    foreach (var item in handshakeList.Values)
                    {
                        if (item.TimeClips < 0)
                        {
                            item.Close();
                        }
                    }
                    foreach (var item in normalList.Values)
                    {
                        if (item.TimeClips < 0)
                        {
                            item.Close();
                        }
                    }
                    foreach (var item in rtrList)
                    {
                        if (item.TimeClips < 0)
                        {
                            item.Close();
                        }
                    }
                }
            }
        }
示例#2
0
        void WriteDataRTR()
        {
            Task.Run(() => {
                var rnd = new HermitLib.Random();

                while (this.Status == ServerSocketStatus.RTR)
                {
                    var cache = new byte[rnd.Next(64, 1024)];
                    rnd.NextBytes(ref cache);
                    WriteDataEx(cache);

                    //30s-60s
                    Thread.Sleep(rnd.Next(10 * 1000, 60 * 1000));
                }
            });
        }