static void Main(string[] args) { #if TEST_CENTER_CLIENT CenterClientApi.HandleNameHandleChangedCallback cb1 = HandleNameHandleChanged; CenterClientApi.HandleMessageCallback cb2 = HandleMessage; CenterClientApi.HandleMessageResultCallback cb3 = HandleMessageResult; CenterClientApi.HandleCommandCallback cb4 = HandleCommand; byte[] bytes = Encoding.ASCII.GetBytes("test test test"); CenterClientApi.Init("csharpclient", args.Length, args, cb1, cb2, cb3, cb4); CenterClientApi.ReloadConfigScript(); CenterClientApi.ReloadConfigScript(); for (; ;) { CenterClientApi.Tick(); Thread.Sleep(10); int handle = CenterClientApi.TargetHandle("ServerCenter"); if (handle > 0) { bool ret = CenterClientApi.SendByHandle(handle, bytes, (ushort)bytes.Length); CenterClientApi.SendCommandByHandle(handle, "output('test test test');"); } } //CenterClientApi.Release(); #else CenterHubApi.HandleNameHandleChangedCallback cb1 = HandleNameHandleChanged2; CenterHubApi.HandleMessageCallback cb2 = HandleMessage2; CenterHubApi.HandleMessageResultCallback cb3 = HandleMessageResult2; CenterHubApi.HandleCommandCallback cb4 = HandleCommand2; byte[] bytes = Encoding.ASCII.GetBytes("test test test"); CenterHubApi.Init("centerhub", args.Length, args, cb1, cb2, cb3, cb4); CenterHubApi.ReloadConfigScript(); CenterHubApi.ReloadConfigScript(); for (; ;) { CenterHubApi.Tick(); Thread.Sleep(10); int handle = CenterHubApi.TargetHandle(0, "hub2world0"); if (handle > 0) { bool ret = CenterHubApi.SendByHandle(0, handle, bytes, (ushort)bytes.Length); CenterHubApi.SendCommandByHandle(0, handle, "output('test test test');"); } handle = CenterHubApi.TargetHandle(1, "hub2world1"); if (handle > 0) { bool ret = CenterHubApi.SendByHandle(1, handle, bytes, (ushort)bytes.Length); CenterHubApi.SendCommandByHandle(1, handle, "output('test test test');"); } } //CenterHubApi.Release(); #endif }
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); } }
private void Loop() { try { while (CenterClientApi.IsRun()) { CenterClientApi.Tick(); Thread.Sleep(10); } } catch (Exception ex) { LogSys.Log(LOG_TYPE.ERROR, "ServerBridge.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
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); } }
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); } }
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); } }
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, "RoomServer Network Tick:{0}", curTime - m_LastTickTime); } } m_LastTickTime = curTime; CenterClientApi.Tick(); Tick(); Thread.Sleep(10); } } catch (Exception ex) { LogSys.Log(LOG_TYPE.ERROR, "RoomServer.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
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); } }