예제 #1
0
        public override void Stop()
        {
            m_shutdown = true;
            base.Stop();

            if (m_realmLists.Count > 0)
            {
                IEnumerator e = m_realmLists.Keys.GetEnumerator();
                while (e.MoveNext())
                {
                    RealmListUpdater updater = (RealmListUpdater)e.Current;
                    updater.Close();
                }
                m_realmLists.Clear();
            }

            m_running = false;
        }
예제 #2
0
        private static void mainThread()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            Socket   sock       = null;
            DateTime LastUpdate = DateTime.MinValue;
            TimeSpan span;

            try
            {
                while (!m_shutdown)
                {
                    while ((sock = acceptSocket()) != null)
                    {
                        try
                        {
                            sock.Send(tehAddress);
                        }
                        catch (SocketException) {}

                        sock.Shutdown(SocketShutdown.Both);
                        sock.Close();
                        sock = null;
                    }
                    DateTime now = DateTime.Now;
                    span = now.Subtract(LastUpdate);
                    if (span.TotalSeconds > 30)
                    {
                        UpdateRealmLists();
                        LastUpdate = now;
                    }
                    UpdatersWork();
                    Thread.Sleep(50);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception e)
            {
                Console.WriteLine("RedirectServer:Unhandled exception!");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            Listener.Close();
            Listener = null;
            try
            {
                if (sock != null)
                {
                    sock.Close();
                }
            }
            catch (Exception) {}            // just incase
            if (ServerStop != null)
            {
                ServerStop();
            }
            if (m_realmLists.Count > 0)
            {
                IEnumerator e = m_realmLists.Keys.GetEnumerator();
                while (e.MoveNext())
                {
                    RealmListUpdater updater = (RealmListUpdater)e.Current;
                    updater.Close();
                }
                m_realmLists.Clear();
            }
            m_running = false;
        }