Exemplo n.º 1
0
        /// <summary>
        /// Closes all & saves all statistics.
        /// </summary>
        public void CloseAll()
        {
            RoleplayManager.saveAllStats();
            Out.WriteLine("Done saving users stats!");

            Bounties.SaveBounty();
            Out.WriteLine("Done saving all bounties!");

            foreach (GameClient client in Clients.Values.Where(client => client.GetHabbo() != null))
            {
                if (client == null)
                {
                    continue;
                }

                if (client.GetHabbo() != null)
                {
                    try
                    {
                        using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunFastQuery(client.GetHabbo().GetQueryString);
                        }
                        Console.Clear();
                        Out.WriteLine("<<- SERVER SHUTDOWN ->> IVNENTORY IS SAVING");
                    }
                    catch
                    {
                    }
                }
            }

            Out.WriteLine("Done saving users inventory!");
            Out.WriteLine("Closing server connections...");
            try
            {
                foreach (GameClient client2 in Clients.Values.Where(client2 => client2.GetHabbo() != null))
                {
                    if (client2 == null || client2.GetConnection() == null)
                    {
                        continue;
                    }

                    try
                    {
                        client2.GetConnection().Dispose();
                    }
                    catch { }

                    Console.Clear();
                    Out.WriteLine("<<- SERVER SHUTDOWN ->> CLOSING CONNECTIONS");
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException(e.ToString());
            }

            if (Clients.Count > 0)
            {
                Clients.Clear();
            }

            Out.WriteLine("Connections closed!");
        }