示例#1
0
        static void UpdateRealmLists()
        {
            IEnumerator e = new ArrayList(m_realmLists.Keys).GetEnumerator();

            while (e.MoveNext())
            {
                RealmListUpdater updater = (RealmListUpdater)e.Current;
                updater.UpdateRealmList(Description, AddressString, LoginServer.CurrentUsers);
                if (updater.Connected == false)
                {
                    RemoveRealmList(updater);
                }
            }
        }
示例#2
0
        static void UpdatersWork()
        {
            IEnumerator e = new ArrayList(m_realmLists.Keys).GetEnumerator();

            while (e.MoveNext())
            {
                RealmListUpdater updater = (RealmListUpdater)e.Current;
                updater.Work();
                if (updater.Connected == false)
                {
                    RemoveRealmList(updater);
                }
            }
        }
示例#3
0
 void UpdateRealmLists()
 {
     lock (this)
     {
         IEnumerator e    = new ArrayList(m_realmLists.Keys).GetEnumerator();
         string      addr = LoginServer.RemoteEndPoint.ToString();
         while (e.MoveNext())
         {
             RealmListUpdater updater = (RealmListUpdater)e.Current;
             updater.UpdateRealmList(Description, addr, LoginServer.CurrentUsers);
             if (updater.Connected == false)
             {
                 RemoveRealmList(updater);
             }
         }
     }
 }
示例#4
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;
        }
示例#5
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;
        }
示例#6
0
 public static void RemoveRealmList(RealmListUpdater updater)
 {
     m_realmLists.Remove(updater);
 }
示例#7
0
 public static void AddRealmList(RealmListUpdater updater)
 {
     m_realmLists[updater] = updater;
 }