Beispiel #1
0
 private void ServerInternalShutdown(AbstractServer server, Protocol.Gluon.Model.ShutdownType data)
 {
     lock (Servers)
     {
         Servers.Remove(server);
     }
     ShutdownMode = data;
 }
Beispiel #2
0
        private async void RequestedShutdown(uint time, Protocol.Gluon.Model.ShutdownType type)
        {
            //TODO: select which shards to operate on
            ShutdownMode = type;
            LOG.Info("Shutdown requested in " + time + " seconds.");

            var remaining = (int)time;

            foreach (var alertTime in ShutdownAlertTimings)
            {
                if (remaining < alertTime)
                {
                    continue;
                }
                //wait until this alert time and display an announcement
                var waitTime = remaining - alertTime;
                await Task.Delay((int)waitTime * 1000);

                remaining -= waitTime;

                string timeString = (remaining % 60 == 0 && remaining > 60) ? ((remaining / 60) + " minutes") : (remaining + " seconds");
                LOG.Info("Shutdown in " + timeString);
                BroadcastMessage("FreeSO Server", "Shutting down", "The game server will go down for maintainance in " + timeString + ".");
            }

            await Task.Delay((int)remaining * 1000);

            LOG.Info("Shutdown commencing.");
            List <Task <bool> > ShutdownTasks = new List <Task <bool> >();

            foreach (var city in CityServers)
            {
                ShutdownTasks.Add(city.Shutdown(type));
            }
            await Task.WhenAll(ShutdownTasks.ToArray());

            LOG.Info("Successfully shut down all city servers!");
            lock (Servers)
            {
                if (ActiveApiServer != null)
                {
                    ActiveApiServer.Shutdown();
                    Servers.Remove(ActiveApiServer);
                }
                if (ActiveUApiServer != null)
                {
                    ActiveUApiServer.Shutdown();
                    Servers.Remove(ActiveUApiServer);
                }
                if (ActiveTaskServer != null)
                {
                    ActiveTaskServer.Shutdown();
                    Servers.Remove(ActiveTaskServer);
                }
            }
        }