Exemplo n.º 1
0
        public void Timeout(string user, int duration = 600)
        {
            StartTimeoutThread();

            if (duration <= 0)
            {
                duration = 1;
            }

            int delay = TimeoutDelay;

            if (delay <= 0)
            {
                TimeoutRaw(user, duration);
            }
            else if (delay <= 150)
            {
                Thread.Sleep(delay);
                TimeoutRaw(user, duration);
            }
            else
            {
                var request = new TimeoutRequest(this, user, duration);
                m_timeouts.Add(request);
            }
        }
Exemplo n.º 2
0
        private void ProcessNext(TimeoutRequest evt)
        {
            int delay = TimeoutDelay;

            delay -= (int)evt.Created.Elapsed().TotalMilliseconds;
            if (delay > 0)
            {
                Thread.Sleep(delay);
            }
            evt.Execute();
        }
Exemplo n.º 3
0
        private void TimeoutThread(object obj)
        {
            while (!m_shutdown)
            {
                TimeoutRequest evt;
                if (!m_timeouts.TryTake(out evt))
                {
                    Thread.Sleep(100);
                    continue;
                }

                ProcessNext(evt);

                while (evt.IsBan)
                {
                    TimeoutRequest next = null;
                    for (int i = 0; i < 15; i++)
                    {
                        Thread.Sleep(100);
                        if (m_shutdown)
                        {
                            return;
                        }

                        if (m_timeouts.TryTake(out next))
                        {
                            evt.Execute();
                            ProcessNext(next);
                            break;
                        }
                    }

                    if (next == null)
                    {
                        evt.Execute();
                        break;
                    }

                    evt = next;
                }
            }
        }
Exemplo n.º 4
0
        public void Ban(string user)
        {
            StartTimeoutThread();

            int delay = TimeoutDelay;

            if (delay <= 0)
            {
                BanRaw(user);
            }
            else if (delay <= 150)
            {
                Thread.Sleep(delay);
                BanRaw(user);
            }
            else
            {
                var request = new TimeoutRequest(this, user, -1);
                m_timeouts.Add(request);
            }
        }
Exemplo n.º 5
0
        private void ProcessNext(TimeoutRequest evt)
        {
            int delay = TimeoutDelay;

            delay -= (int)evt.Created.Elapsed().TotalMilliseconds;
            if (delay > 0)
                Thread.Sleep(delay);
            evt.Execute();
        }
Exemplo n.º 6
0
        public void Timeout(string user, int duration = 600)
        {
            StartTimeoutThread();

            if (duration <= 0)
                duration = 1;

            int delay = TimeoutDelay;
            if (delay <= 0)
            {
                TimeoutRaw(user, duration);
            }
            else if (delay <= 150)
            {
                Thread.Sleep(delay);
                TimeoutRaw(user, duration);
            }
            else
            {
                var request = new TimeoutRequest(this, user, duration);
                m_timeouts.Add(request);
            }
        }
Exemplo n.º 7
0
        public void Ban(string user)
        {
            StartTimeoutThread();

            int delay = TimeoutDelay;
            if (delay <= 0)
            {
                BanRaw(user);
            }
            else if (delay <= 150)
            {
                Thread.Sleep(delay);
                BanRaw(user);
            }
            else
            {
                var request = new TimeoutRequest(this, user, -1);
                m_timeouts.Add(request);
            }
        }
Exemplo n.º 8
0
        private void ProcessNext(TimeoutRequest evt)
        {
            int delay = TimeoutDelay;

            delay -= (int)evt.Created.Elapsed().TotalMilliseconds;
            if (delay > 0)
                Thread.Sleep(delay);
            evt.Execute();
            Console.WriteLine("[{0}] ProcessingBan {1} msec", DateTime.Now, evt.Created.Elapsed().TotalMilliseconds);
        }