private static Embed GetServerEmbed(ServerStatusModel server) { if (server?.ServerInfo == null || server.GameInfo == null || server.ServerInfo.Hidden || server.GameInfo.PlayerCount == 0) { return(null); } var builder = new EmbedBuilder { Title = $"**{server.ServerInfo.Name}**" }; builder.AddField("Map", server.GameInfo.CurrentMap.EscapeDiscordChars()); if (server.GameInfo.NextMap != null) { builder.AddField("Next Map", server.GameInfo.NextMap.ToString().EscapeDiscordChars()); } builder.AddField("Connect", $"[{server.ServerInfo.Addr}](steam://connect/{server.ServerInfo.Addr}:{server.ServerInfo.Port})" .EscapeDiscordChars()) .AddField("Players Online", server.GameInfo.PlayerCount + "/" + server.GameInfo.MaxPlayers) .WithColor(ColorConstants.InfoColor); if (server.GameInfo.Users.Any()) { builder.AddField("Player List", server.GameInfo.Users.OrderBy(x => x.Name).Aggregate("", (currentString, nextPlayer) => currentString + "**" + nextPlayer.Name + "**" + ", ") .TrimEnd(',', ' ')); } return(builder.Build()); }
private void Application_Startup(object sender, StartupEventArgs e) { LogModel = new LogModel(); ServerStatusModel = new ServerStatusModel(); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); striveEngine.Start(); }
public void Modify() { var serverStatus = new ServerStatusModel(); var result = serverStatusAppService.Modify(serverStatus); Assert.IsNotNull(result); }
public Engine() { _log.Info("Creating " + Assembly.GetExecutingAssembly().GetName().FullName); Global.ReadConfiguration(); //Global.worldFilename = "DefaultWorld.xml"; _engineThread = new StoppableThread(UpdateLoop); _listener = new Listener(new IPEndPoint(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0], port)); _log = LogManager.GetCurrentClassLogger(); ServerStatusModel = new ServerStatusModel {Status = "Created"}; }
/// <summary> /// 获取服务站状态 /// </summary> /// <returns></returns> public static DataTable GetServerStatus() { ServerStatusModel ssm = new ServerStatusModel(); ssm.ServerStatus = GlobalStaticObj_Server.ConnStatus ? "1" : "0"; ssm.clientNums = LoginSessionInfo.Instance.dicLoginInfos.Count.ToString(); ssm.ytCrmLinkedStatus = "1"; ssm.csComId = GlobalStaticObj_Server.Instance.ComID; ssm.comId = GlobalStaticObj_Server.Instance.ComID; return(ssm.GetDataTable()); }
public Engine() { _log.Info("Creating " + Assembly.GetExecutingAssembly().GetName().FullName); Global.ReadConfiguration(); //Global.worldFilename = "DefaultWorld.xml"; _engineThread = new StoppableThread(UpdateLoop); _listener = new Listener(new IPEndPoint(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0], port)); _log = LogManager.GetCurrentClassLogger(); ServerStatusModel = new ServerStatusModel { Status = "Created" }; }
internal static Embed GetServerStatusAsync(ServerStatusModel server) { try { var embed = GetServerEmbed(server); return(embed); } catch (Exception e) { return(Logger.LogException(e)); } }
public ActionResult Edit([FromBody] ServerStatusModel item) { try { app.Modify(item); } catch (Exception) { return(BadRequest("Error while editing item")); } return(NoContent()); }
public void Add() { var serverStatus = new ServerStatusModel() { EndSessionTimestamp = null, IdServer = 1, IdServerStatus = 2, IsSessionActive = false, StartSessionTimestamp = DateTime.Now, UserInSession = "" }; var result = serverStatusAppService.Add(serverStatus); Assert.IsNotNull(result); }
public ActionResult <ServerStatusModel> Create([FromBody] ServerStatusModel model) { app.Add(model); return(CreatedAtAction(nameof(GetItem), new { model.IdServer }, model)); }
public ServerStatusViewModel(ServerStatusModel serverStatusModel) { ServerStatusModel = serverStatusModel; }