Exemplo n.º 1
0
        /// <summary>
        ///     Mark all users as disconnected, fixes chat history repeat
        /// </summary>
        public void Shutdown()
        {
            Broadcast(ConnectedUsers.Values,
                      new Say()
            {
                User  = GlobalConst.NightwatchName,
                Text  = "Zero-K server restarted for upgrade, be back soon",
                Place = SayPlace.MessageBox,
            });

            RatingSystems.BackupToDB();

            var db = new ZkDataContext();

            foreach (var u in ConnectedUsers.Values)
            {
                if (u != null && u.IsLoggedIn)
                {
                    var acc = db.Accounts.Find(u.User.AccountID);
                    acc.LastLogout = DateTime.UtcNow;
                }
            }
            db.SaveChanges();


            // close all existing client connections
            foreach (var usr in ConnectedUsers.Values)
            {
                if (usr != null)
                {
                    foreach (var con in usr.Connections.Keys)
                    {
                        con?.RequestClose();
                    }
                }
            }


            //foreach (var bat in Battles.Values) if (bat != null && bat.spring.IsRunning) bat.spring.ExitGame();
        }