예제 #1
0
    private void Loop()
    {
        try {
            while (CenterClientApi.IsRun())
            {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastTickTime != 0)
                {
                    long elapsedTickTime = curTime - m_LastTickTime;
                    if (elapsedTickTime > c_WarningTickTime)
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "DataCache Network Tick:{0}", curTime - m_LastTickTime);
                    }
                }
                m_LastTickTime = curTime;

                CenterClientApi.Tick();
                Thread.Sleep(10);
                if (m_WaitQuit)
                {
                    if (PersistentSystem.Instance.StartLastSaveResult == PersistentSystem.SaveState.Failed)
                    {
                        //发起存盘操作失败,重置m_WaitQuit
                        m_WaitQuit = false;
                    }
                    if (PersistentSystem.Instance.LastSaveState == PersistentSystem.SaveState.Success)
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "DataCache LastSave Success. DataCache quit ...");
                        Thread.Sleep(10000);
                        CenterClientApi.Quit();
                    }
                    else if (PersistentSystem.Instance.LastSaveState == PersistentSystem.SaveState.Failed)
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "DataCache LastSave Failed. DataCache NOT quit ...");
                        PersistentSystem.Instance.LastSaveState = PersistentSystem.SaveState.Initial;
                        m_WaitQuit = false;
                    }
                }
                if (m_LastEchoTime + 5000 < curTime)
                {
                    m_LastEchoTime = curTime;

                    CenterClientApi.SendCommandByName("DataCache", "Echo");
                }
            }
        } catch (Exception ex) {
            LogSys.Log(LOG_TYPE.ERROR, "DataCache.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
        }
    }
예제 #2
0
 private void OnCommand(int src, int dest, string command)
 {
     try
     {
         if (0 == command.CompareTo("QuitServerBridge"))
         {
             LogSys.Log(LOG_TYPE.MONITOR, "receive {0} command, quit", command);
             CenterClientApi.Quit();
         }
     }
     catch (Exception ex)
     {
         LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
예제 #3
0
 private void Loop()
 {
     try
     {
         while (CenterClientApi.IsRun())
         {
             CenterClientApi.Tick();
             Thread.Sleep(10);
             if (m_WaitQuit && m_GlobalDataProcessThread.LastSaveFinished && m_DataProcessScheduler.LastSaveFinished)
             {
                 LogSys.Log(LOG_TYPE.MONITOR, "Lobby quit.");
                 CenterClientApi.Quit();
             }
         }
     }
     catch (Exception ex)
     {
         LogSys.Log(LOG_TYPE.ERROR, "Lobby.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
예제 #4
0
        private void OnCommand(int src, int dest, string command)
        {
            const string c_QuitRoomServer = "QuitRoomServer";
            const string c_ReloadConfig   = "ReloadConfig";

            try {
                if (0 == command.CompareTo(c_QuitRoomServer))
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "receive {0} command, quit", command);
                    CenterClientApi.Quit();
                }
                else if (0 == command.CompareTo(c_ReloadConfig))
                {
                    CenterClientApi.ReloadConfigScript();
                    InitConfig();
                    LogSys.Log(LOG_TYPE.WARN, "receive {0} command.", command);
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
예제 #5
0
 private void Loop()
 {
     try
     {
         while (CenterClientApi.IsRun())
         {
             CenterClientApi.Tick();
             Thread.Sleep(10);
             if (m_WaitQuit && PersistentSystem.Instance.LastSaveFinished)
             {
                 DataOpSystem.Instance.Enable = false;
                 LogSys.Log(LOG_TYPE.MONITOR, "DataStore quit.");
                 CenterClientApi.Quit();
             }
         }
     }
     catch (Exception ex)
     {
         LogSys.Log(LOG_TYPE.ERROR, "DataStore.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
예제 #6
0
        private void Loop()
        {
            try {
                while (CenterClientApi.IsRun())
                {
                    long curTime = TimeUtility.GetLocalMilliseconds();
                    if (m_LastTickTime != 0)
                    {
                        long elapsedTickTime = curTime - m_LastTickTime;
                        if (elapsedTickTime > c_WarningTickTime)
                        {
                            LogSys.Log(LOG_TYPE.MONITOR, "Lobby Network Tick:{0}", curTime - m_LastTickTime);
                        }
                    }
                    m_LastTickTime = curTime;

                    CenterClientApi.Tick();
                    Thread.Sleep(10);
                    if (m_WaitQuit)
                    {
                        //等待10s
                        long startTime = TimeUtility.GetLocalMilliseconds();
                        while (startTime + 10000 > TimeUtility.GetLocalMilliseconds())
                        {
                            CenterClientApi.Tick();
                            Thread.Sleep(10);
                        }
                        //关闭Lobby
                        LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_3. LastSaveDone. Lobby quit...");
                        CenterClientApi.Quit();
                    }
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Lobby.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
예제 #7
0
        private void Loop()
        {
            try {
                while (CenterHubApi.IsRun())
                {
                    long curTime = TimeUtility.GetLocalMilliseconds();
                    if (m_LastTickTime != 0)
                    {
                        long elapsedTickTime = curTime - m_LastTickTime;
                        if (elapsedTickTime > c_WarningTickTime)
                        {
                            LogSys.Log(LOG_TYPE.MONITOR, "GameFramework Network Tick:{0}", curTime - m_LastTickTime);
                        }
                    }
                    m_LastTickTime = curTime;

                    CenterHubApi.Tick();
                    Thread.Sleep(10);
                    if (m_WaitQuit)
                    {
                        if (m_GlobalProcessThread.LastSaveFinished && m_UserProcessScheduler.LastSaveFinished && m_QuitFinish == false)
                        {
                            //全局数据和玩家数据存储完毕
                            int saveReqCount = m_DataCacheThread.CalcSaveRequestCount();
                            LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_1. GlobalData and UserData last save done. SaveRequestCount:{0}", saveReqCount);
                            if (saveReqCount > 0)
                            {
                                //等待5s
                                long startTime = TimeUtility.GetLocalMilliseconds();
                                while (startTime + 5000 > TimeUtility.GetLocalMilliseconds())
                                {
                                    CenterClientApi.Tick();
                                    Thread.Sleep(10);
                                }
                            }
                            else
                            {
                                //通知关闭DataCache
                                m_QuitFinish = true;
                                LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_2. Notice DataCache to quit.");
                                CenterClientApi.SendCommandByName("DataCache", "QuitDataStore");
                                //等待10s
                                long startTime = TimeUtility.GetLocalMilliseconds();
                                while (startTime + 10000 > TimeUtility.GetLocalMilliseconds())
                                {
                                    CenterClientApi.Tick();
                                    Thread.Sleep(10);
                                }
                                //关闭GameFramework
                                LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_3. LastSaveDone. GameFramework quit...");
                                CenterClientApi.Quit();
                            }
                        }
                        else
                        {
                            if (curTime - m_LastWaitQuitTime > c_WaitQuitTimeInterval)
                            {
                                m_WaitQuit = false;
                                LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_-1. Reset m_WaitQuit to false.");
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "GameFramework.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
            }
        }