コード例 #1
0
        public static void shutDown()
        {
            if (!_RunningServer)
            {
                Environment.Exit(0);
                return;
            }
            try
            {
                for (int I = 1; I <= 3; I++)
                {
                    foreach (virtualRoom _Room in RoomManager.getRoomsInChannel(I))
                    {
                        if (_Room == null)
                        {
                            continue;
                        }
                        _Room.endGame();
                    }
                }
            }
            catch { }
            DB.closeConnection();
            MYSQL.closeConnection();
            Thread.Sleep(5000);

            try
            {
                foreach (virtualUser _User in UserManager.getAllUsers())
                {
                    if (_User == null)
                    {
                        continue;
                    }
                    _User.disconnect();
                }
            }
            catch { }

            //Environment.Exit(0);

            _RunningServer = false;

            try
            {
                if (_ServerThread.IsAlive)
                {
                    _ServerThread.Abort();
                }
            }
            catch { }

            try
            {
                if (_CommandThread.IsAlive)
                {
                    _CommandThread.Abort();
                }
            }
            catch { }

            Program.sClient.CloseSocket();
            GameServer.NetworkSocket.CloseSocket();

            DB.runQuery("UPDATE users SET online='0'");
            Log.AppendText("All accounts have been set offline");
            Environment.Exit(0);
        }