public JObject ExtendMaintenance() { if (ServerStatus.Status == ServerStatusType.MAINTENANCE && this.Request.Query.TryGetValue("duration", out StringValues durationStr)) { ServerStatus.SetStatus(ServerStatusType.MAINTENANCE, TimeUtil.GetTimestamp() + LogicMath.Max(int.Parse(durationStr) * 60, 0), 0); return(this.BuildResponse(HttpStatusCode.OK)); } return(this.BuildResponse(HttpStatusCode.Forbidden)); }
public JObject CancelCooldown() { if (ServerStatus.Status == ServerStatusType.COOLDOWN_AFTER_MAINTENANCE) { ServerStatus.SetStatus(ServerStatusType.NORMAL, 0, 0); return(this.BuildResponse(HttpStatusCode.OK)); } return(this.BuildResponse(HttpStatusCode.Forbidden)); }
public JObject StopMaintenance() { if (ServerStatus.Status == ServerStatusType.MAINTENANCE) { ServerStatus.SetStatus(ServerStatusType.COOLDOWN_AFTER_MAINTENANCE, TimeUtil.GetTimestamp() + 300, 0); return(this.BuildResponse(HttpStatusCode.OK)); } return(this.BuildResponse(HttpStatusCode.Forbidden)); }
public JObject StartMaintenance() { if ((ServerStatus.Status == ServerStatusType.NORMAL || ServerStatus.Status == ServerStatusType.COOLDOWN_AFTER_MAINTENANCE) && this.Request.Query.TryGetValue("duration", out StringValues durationStr)) { ServerStatus.SetStatus(ServerStatusType.SHUTDOWN_STARTED, TimeUtil.GetTimestamp() + 300, LogicMath.Max(int.Parse(durationStr) * 60, 0)); return(this.BuildResponse(HttpStatusCode.OK)); } return(this.BuildResponse(HttpStatusCode.Forbidden)); }
public static void Main(string[] args) { ServerCore.Init(0, args); ServerAdmin.Init(); ServerCore.Start(new AdminMessageManager()); if (EnvironmentSettings.Environment.Equals("prod", StringComparison.InvariantCultureIgnoreCase)) { ServerStatus.SetStatus(ServerStatusType.MAINTENANCE, 0, 0); } Program.CreateWebHostBuilder(args).Build().Run(); }
private static void Update() { Thread.Sleep(5000); int counter = 0; while (true) { if (ServerStatus.Status == ServerStatusType.SHUTDOWN_STARTED && ServerStatus.Time - TimeUtil.GetTimestamp() < 0) { ServerStatus.SetStatus(ServerStatusType.MAINTENANCE, ServerStatus.NextTime + TimeUtil.GetTimestamp(), 0); } if (ServerStatus.Status == ServerStatusType.COOLDOWN_AFTER_MAINTENANCE && ServerStatus.Time - TimeUtil.GetTimestamp() < 0) { ServerStatus.SetStatus(ServerStatusType.NORMAL, 0, 0); } if (counter++ % 20 == 0) { for (int i = 0; i < EnvironmentSettings.SERVER_TYPE_COUNT; i++) { ServerPerformance[] entryArray = ServerManager.m_entry[i]; for (int j = 0; j < entryArray.Length; j++) { entryArray[j].SendPingMessage(); } } for (int i = 0; i < EnvironmentSettings.SERVER_TYPE_COUNT; i++) { ServerPerformance[] entryArray = ServerManager.m_entry[i]; for (int j = 0; j < entryArray.Length; j++) { ServerMessageManager.SendMessage(new ServerPerformanceMessage(), entryArray[j].Socket); } } if (counter == 20) { counter = 1; } } Thread.Sleep(500); } }
internal static bool ReceiveCoreMessage(ServerCoreMessage message) { switch (message.GetMessageType()) { case ServerMessageType.PING: ServerMessageManager.SendMessage(new PongMessage(), message.Sender); return(true); case ServerMessageType.SERVER_STATUS: ServerStatusMessage serverStatusMessage = (ServerStatusMessage)message; ServerStatus.SetStatus(serverStatusMessage.Type, serverStatusMessage.Time, serverStatusMessage.NextTime); return(true); default: return(false); } }