IW4M-Admin/WebfrontCore/ViewComponents/ServerListViewComponent.cs
RaidMax 6d8d021b16 auth cookie expires after 30 days
only check hit offset when distance > 3 meters
fix null reference on unauthorized user
fixed stats not showing on profile if anticheat disabled
server client history turns red server is unresponsive
2018-04-04 23:38:45 -05:00

40 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.ViewComponents
{
public class ServerListViewComponent : ViewComponent
{
public IViewComponentResult Invoke()
{
var servers = IW4MAdmin.Program.ServerManager.GetServers();
var serverInfo = servers.Select(s => new ServerInfo()
{
Name = s.Hostname,
ID = s.GetHashCode(),
Port = s.GetPort(),
Map = s.CurrentMap.Alias,
ClientCount = s.ClientNum,
MaxClients = s.MaxClients,
GameType = s.Gametype,
PlayerHistory = s.PlayerHistory.ToArray(),
Players = s.Players.Where(p => p != null)
.Select(p => new PlayerInfo()
{
Name = p.Name,
ClientId = p.ClientId,
Level = p.Level.ToString(),
LevelInt = (int)p.Level
}).ToList(),
ChatHistory = s.ChatHistory.ToArray(),
Online = !s.Throttled
}).ToList();
return View("_List", serverInfo);
}
}
}