public override void OnReceiveCoreMessage(ServerCoreMessage message) { switch (message.GetMessageType()) { case ServerMessageType.SERVER_PERFORMANCE: ServerMessageManager.SendMessage(new ServerPerformanceDataMessage { SessionCount = GameModeClusterManager.SessionCount, ClusterCount = GameModeClusterManager.ClusterCount }, message.Sender); GameModeClusterManager.StartPing(); break; } }
public override void OnReceiveSessionMessage(ServerSessionMessage message) { switch (message.GetMessageType()) { case ServerMessageType.START_SERVER_SESSION: GameModeClusterManager.OnStartServerSessionMessageReceived((StartServerSessionMessage)message); break; case ServerMessageType.STOP_SERVER_SESSION: GameModeClusterManager.OnStopServerSessionMessageReceived((StopServerSessionMessage)message); break; default: GameModeClusterManager.ReceiveMessage(message); break; } }
public void OnClientTurnReceived(int subTick, int checksum, LogicArrayList <LogicCommand> commands) { if (this.m_destructed || this.m_logicGameMode.GetState() == 4 || this.m_logicGameMode.GetState() == 5) { return; } int currentTimestamp = TimeUtil.GetTimestamp(); int logicTimestamp = this.m_logicGameMode.GetStartTime() + LogicTime.GetTicksInSeconds(subTick); if (currentTimestamp + 1 >= logicTimestamp) { if (commands != null) { this.m_serverCommandStorage.CheckExecutableServerCommands(subTick, commands); for (int i = 0; i < commands.Size(); i++) { this.m_logicGameMode.GetCommandManager().AddCommand(commands[i]); } } int previousSubTick = this.m_logicGameMode.GetLevel().GetLogicTime().GetTick(); try { this.m_logicWatch.Start(); for (int i = 0, count = subTick - previousSubTick; i < count; i++) { this.m_logicGameMode.UpdateOneSubTick(); if (this.m_logicWatch.ElapsedMilliseconds >= GameMode.MAX_LOGIC_LOOP_TIME) { Logging.Error(string.Format("GameMode.onClientTurnReceived: logic update stopped because it took too long. ({0}ms for {1} updates)", this.m_logicWatch.ElapsedMilliseconds, i)); break; } } GameModeClusterManager.ReportLogicUpdateSpeed(this.m_logicWatch.ElapsedMilliseconds); this.m_logicWatch.Reset(); } catch (LogicException exception) { Logging.Error("GameMode.onClientTurnReceived: logic exception thrown: " + exception + " (acc id: " + (long)this.m_session.AccountId + ")"); ServerErrorMessage serverErrorMessage = new ServerErrorMessage(); serverErrorMessage.SetErrorMessage(exception.Message); this.m_session.SendPiranhaMessage(serverErrorMessage, 1); this.m_session.SendMessage(new StopSessionMessage(), 1); } catch (Exception exception) { Logging.Error("GameMode.onClientTurnReceived: exception thrown: " + exception + " (acc id: " + (long)this.m_session.AccountId + ")"); this.m_session.SendMessage(new StopSessionMessage(), 1); } this.CheckChecksum(checksum); if (this.m_avatarChangeListener != null) { this.SaveState(); } if (this.m_liveReplayId != null) { this.UpdateLiveReplay(subTick, commands); } if (this.m_logicGameMode.IsBattleOver()) { this.m_shouldDestruct = true; } if (this.m_shouldDestruct) { this.m_session.DestructGameMode(); } } else { this.m_session.SendMessage(new StopSessionMessage(), 1); } }
public static void Init() { GameModeClusterManager.Init(); }