2018-02-21 20:29:23 -05:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2018-08-03 22:11:58 -04:00
|
|
|
|
using SharedLibraryCore;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Dtos;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.Controllers
|
|
|
|
|
{
|
2018-03-06 02:22:19 -05:00
|
|
|
|
public class ServerController : BaseController
|
2018-02-21 20:29:23 -05:00
|
|
|
|
{
|
|
|
|
|
[HttpGet]
|
2018-02-22 01:06:21 -05:00
|
|
|
|
[ResponseCache(NoStore = true, Duration = 0)]
|
2018-02-21 20:29:23 -05:00
|
|
|
|
public IActionResult ClientActivity(int id)
|
|
|
|
|
{
|
2018-03-06 02:22:19 -05:00
|
|
|
|
var s = Manager.GetServers().FirstOrDefault(s2 => s2.GetHashCode() == id);
|
2018-02-21 20:29:23 -05:00
|
|
|
|
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,
|
2018-05-14 13:55:10 -04:00
|
|
|
|
Players = s.GetPlayersAsList()
|
|
|
|
|
.Select(p => new PlayerInfo
|
2018-02-21 20:29:23 -05:00
|
|
|
|
{
|
|
|
|
|
Name = p.Name,
|
2018-03-28 23:01:09 -04:00
|
|
|
|
ClientId = p.ClientId,
|
2018-08-03 22:11:58 -04:00
|
|
|
|
Level = p.Level.ToLocalizedLevelName(),
|
2018-04-02 01:25:06 -04:00
|
|
|
|
LevelInt = (int)p.Level
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}).ToList(),
|
2018-05-14 13:55:10 -04:00
|
|
|
|
ChatHistory = s.ChatHistory,
|
2018-04-05 00:38:45 -04:00
|
|
|
|
PlayerHistory = s.PlayerHistory.ToArray(),
|
2018-02-21 20:29:23 -05:00
|
|
|
|
};
|
|
|
|
|
return PartialView("_ClientActivity", serverInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|