예제 #1
0
 /// <summary>
 ///     Stops the server.
 /// </summary>
 public virtual void Stop()
 {
     _connectionListener?.Stop();
     foreach (IScsServerClient client in Clients.Select(s => s.Value))
     {
         client.Disconnect();
     }
 }
 /// <summary>
 /// Stops the server.
 /// </summary>
 public virtual void Stop()
 {
     _connectionListener?.Stop();
     foreach (IScsServerClient client in Clients.GetAllItems())
     {
         client.Disconnect();
     }
 }
예제 #3
0
        /// <summary>
        /// Stops the server.
        /// </summary>
        public virtual void Stop()
        {
            if (_connectionListener != null)
            {
                _connectionListener.Stop();
            }

            foreach (var client in Clients.Values)
            {
                client.Disconnect();
            }
        }
예제 #4
0
        /// <summary>
        /// Stops the MUD engine.
        ///
        /// From RFE 1063516:
        /// 1. Block any new connections.
        /// 2. Kick all active connections (which causes them to
        ///    save to db automatically)
        /// 3. Backup all items, mobs, and rooms to db.
        /// 4. Save server variables to db, like clock/calendar time.
        /// 5. Exit
        /// </summary>
        public void Stop()
        {
            Lib.PrintLine("Stopping the MUD Server...");

            // Stop the Client Listener
            Lib.PrintLine("Blocking new connections.");
            Lib.PrintLine("Kicking " + tcpListener.ClientCount + " active connections.");
            tcpListener.Stop();
            int counter = 0;

            while (tcpListener.Active)
            {
                Thread.Sleep(100);
                if (counter++ > 30)
                {
                    throw new System.TimeoutException("Could not stop tcpListener in time");
                }
            }

            // Abort system threads
            // testing123
            Lib.PrintLine("Kill system threads.");
            counter = 0;
            timerthread.Abort();
            while (timerthread.IsAlive)
            {
                Thread.Sleep(100);
                if (counter++ > 30)
                {
                    throw new System.TimeoutException("Could not stop timerThread in time");
                }
            }

            // Back up all actors
            lock (Lib.actors.SyncRoot)
            {
                Lib.PrintLine("Backup " + Lib.actors.Count + " actors.");
                foreach (Actor item in Lib.actors)
                {
                    if (item != null)
                    {
                        item.Save();
                    }
                }
            }

            // Back up all spells
            lock (Lib.spells.SyncRoot)
            {
                Lib.PrintLine("Backup " + Lib.spells.Count + " spells.");
                foreach (Spell spell in Lib.spells)
                {
                    if (spell != null)
                    {
                        spell.Save();
                    }
                }
            }

            // Empty system containers
            Lib.PrintLine("Empty system containers.");
            Lib.actors.Clear();
            Lib.Conn.Close();
            Lib.StoryConn.Close();
            CommitStoryDatabase();
            Lib.SystemCommandWords.Clear();
            Lib.PlayerCommandWords.Clear();
            Lib.BuilderCommandWords.Clear();
            Lib.AdminCommandWords.Clear();
            Lib.UberAdminCommandWords.Clear();
            Lib.Actions.Clear();
            Lib.Commands.Clear();
            Lib.spells.Clear();

            Lib.PrintLine("Save server state.");
            Lib.SaveServerState();

            Lib.PrintLine("Shutdown is complete.");
        }
 public void Stop()
 {
     _connectionListener.Stop();
 }