IW4M-Admin/WebfrontCore/Controllers/ServerController.cs
RaidMax 699c19cd4b adding Cod4 support (for steam GUID is truncated to 16 characters)
exit properly whoops
add all linked accounts to drop down
consolidate linked admin accounts to the most recently seen one
limited some waits to 5s to hopefully prevent a rare thread lock
2018-05-14 12:55:10 -05:00

44 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers
{
public class ServerController : BaseController
{
[HttpGet]
[ResponseCache(NoStore = true, Duration = 0)]
public IActionResult ClientActivity(int id)
{
var s = Manager.GetServers().FirstOrDefault(s2 => s2.GetHashCode() == id);
if (s == null)
return View("Error", "Invalid server!");
var serverInfo = new ServerInfo()
{
Name = s.Hostname,
ID = s.GetHashCode(),
Port = s.GetPort(),
Map = s.CurrentMap.Alias,
ClientCount = s.ClientNum,
MaxClients = s.MaxClients,
GameType = s.Gametype,
Players = s.GetPlayersAsList()
.Select(p => new PlayerInfo
{
Name = p.Name,
ClientId = p.ClientId,
Level = p.Level.ToString(),
LevelInt = (int)p.Level
}).ToList(),
ChatHistory = s.ChatHistory,
PlayerHistory = s.PlayerHistory.ToArray(),
};
return PartialView("_ClientActivity", serverInfo);
}
}
}