コード例 #1
0
        public void StopServer()
        {
            bool isSaving = false;

            try
            {
                Log.Instance.Info(HES.Localization.Sentences["ShuttingDown"]);

                if (Server.PersistenceSaveInterval > 0.0)
                {
                    //ServerInstance.Instance.Save();
                    isSaving = true;
                    Stopwatch saveTime = new Stopwatch();
                    saveTime.Start();
                    Console.WriteLine(HES.Localization.Sentences["SavingUniverse"]);
                    Persistence.Save();
                    saveTime.Stop();
                    Log.Instance.Info(
                        string.Format(HES.Localization.Sentences["SavedUniverseTime"],
                                      saveTime.Elapsed.Milliseconds,
                                      string.Format((string)Persistence.PersistanceFileName,
                                                    DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss"))));
                }

                m_closeSocketListeners.Invoke(Server.Instance.NetworkController, null);

                Log.Instance.Info("Logging out all clients...");
                foreach (var client in Server.Instance.NetworkController.ClientList)
                {
                    client.Value.Thread.Stop();

                    if (client.Value.Player != null)
                    {
                        client.Value.Player.LogoutDisconnectReset();
                        client.Value.Player.DiconnectFromNetworkContoller();
                    }
                }
                Server.Instance.NetworkController.ClientList.Clear();

                Dbg.Destroy();

                Log.Instance.Info("Ending the Server loop...");

                Server.MainLoopEnded.WaitOne(5000);

                Log.Instance.Info("Loop ended.");

                ServerInstance.Instance.IsRunning = false;

                GC.Collect();
                GC.WaitForPendingFinalizers();

                Log.Instance.Info(HES.Localization.Sentences["SuccessShutdown"]);
                Server.IsRunning = false;
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex, "Hellion Extended Server [SHUTDOWN ERROR] : " + ex.Message);
            }
        }
コード例 #2
0
ファイル: Hellion.cs プロジェクト: generalwrex/HES_REWRITE
        public void Stop()
        {
            try
            {
                if (Server.PersistenceSaveInterval > 0.0)
                {
                    //ServerInstance.Instance.Save();
                    //Log.Instance.Info(HES.Localization.Sentences["SavingUniverse"]);
                }

                m_closeSocketListeners.Invoke(Server.Instance.NetworkController, null);

                Server.IsRunning = false;

                Dbg.Destroy();
                Server.MainLoopEnded.WaitOne(5000);

                //ServerInstance.Instance.IsRunning = false;

                //Log.Instance.Info(HES.Localization.Sentences["SuccessShutdown"]);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Hellion Extended Server [SHUTDOWN ERROR]");
            }
        }