Exemplo n.º 1
0
        public void CloseAll()
        {
            foreach (GameClient client in GetClients.ToList())
            {
                if (client == null)
                {
                    continue;
                }

                if (client.GetHabbo() != null)
                {
                    try
                    {
                        using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.runFastQuery(client.GetHabbo().GetQueryString);
                        }
                        Console.Clear();
                        log.Info("<<- APAGANDO SERVIDOR ->> GUARDANDO INVENTARIOS");
                    }
                    catch
                    {
                    }
                }
            }

            log.Info("Listo, inventario de los users guardado!");
            log.Info("Cerrando las conexiones del servidor...");
            try
            {
                foreach (GameClient client in GetClients.ToList())
                {
                    if (client == null || client.GetConnection() == null)
                    {
                        continue;
                    }

                    try
                    {
                        CloudServer.GetConnectionManager().Destroy();
                        client.GetConnection().Dispose();
                    }
                    catch (Exception e)
                    {
                        ExceptionLogger.LogException(e);
                    }

                    Console.Clear();
                    log.Info("<<- APAGANDO SERVIDOR ->> Cerrando Conexiones");
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }

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

            log.Info("Conexiones Cerradas!");
        }