Esempio n. 1
0
        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());
        }
Esempio n. 2
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     LogModel          = new LogModel();
     ServerStatusModel = new ServerStatusModel();
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
     striveEngine.Start();
 }
Esempio n. 3
0
        public void Modify()
        {
            var serverStatus = new ServerStatusModel();

            var result = serverStatusAppService.Modify(serverStatus);

            Assert.IsNotNull(result);
        }
Esempio n. 4
0
 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"};
 }
Esempio n. 5
0
        /// <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());
        }
Esempio n. 6
0
 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"
     };
 }
Esempio n. 7
0
 internal static Embed GetServerStatusAsync(ServerStatusModel server)
 {
     try
     {
         var embed = GetServerEmbed(server);
         return(embed);
     }
     catch (Exception e)
     {
         return(Logger.LogException(e));
     }
 }
Esempio n. 8
0
 public ActionResult Edit([FromBody] ServerStatusModel item)
 {
     try
     {
         app.Modify(item);
     }
     catch (Exception)
     {
         return(BadRequest("Error while editing item"));
     }
     return(NoContent());
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 public ActionResult <ServerStatusModel> Create([FromBody] ServerStatusModel model)
 {
     app.Add(model);
     return(CreatedAtAction(nameof(GetItem), new { model.IdServer }, model));
 }
Esempio n. 11
0
 public ServerStatusViewModel(ServerStatusModel serverStatusModel)
 {
     ServerStatusModel = serverStatusModel;
 }