2018-10-15 20:51:04 -04:00
|
|
|
|
using IW4ScriptCommands.Commands;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2018-10-13 19:49:08 -04:00
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.Controllers.API
|
|
|
|
|
{
|
|
|
|
|
[Route("api/gsc/[action]")]
|
|
|
|
|
public class GscApiController : ApiController
|
|
|
|
|
{
|
|
|
|
|
[HttpGet("{networkId}")]
|
|
|
|
|
public IActionResult ClientInfo(string networkId)
|
|
|
|
|
{
|
|
|
|
|
var clientInfo = Manager.GetActiveClients()
|
2019-05-02 23:33:38 -04:00
|
|
|
|
.FirstOrDefault(c => c.NetworkId == networkId.ConvertGuidToLong());
|
2018-10-13 19:49:08 -04:00
|
|
|
|
|
|
|
|
|
if (clientInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
sb.AppendLine($"admin={clientInfo.IsPrivileged()}");
|
|
|
|
|
sb.AppendLine($"level={(int)clientInfo.Level}");
|
|
|
|
|
sb.AppendLine($"levelstring={clientInfo.Level.ToLocalizedLevelName()}");
|
|
|
|
|
sb.AppendLine($"connections={clientInfo.Connections}");
|
|
|
|
|
sb.AppendLine($"authenticated={clientInfo.GetAdditionalProperty<bool>("IsLoggedIn") == true}");
|
|
|
|
|
|
|
|
|
|
return Content(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Content("");
|
|
|
|
|
}
|
2018-10-15 20:51:04 -04:00
|
|
|
|
|
|
|
|
|
[HttpGet("{networkId}")]
|
2018-10-25 09:14:39 -04:00
|
|
|
|
public IActionResult GetTeamAssignments(string networkId, int serverId, string teams = "", bool isDisconnect = false)
|
2018-10-15 20:51:04 -04:00
|
|
|
|
{
|
2018-10-25 09:14:39 -04:00
|
|
|
|
return Unauthorized();
|
|
|
|
|
|
2018-10-15 20:51:04 -04:00
|
|
|
|
var client = Manager.GetActiveClients()
|
2019-05-02 23:33:38 -04:00
|
|
|
|
.FirstOrDefault(c => c.NetworkId == networkId.ConvertGuidToLong());
|
2018-10-25 09:14:39 -04:00
|
|
|
|
|
2018-11-27 19:31:48 -05:00
|
|
|
|
var server = Manager.GetServers().First(c => c.EndPoint == serverId);
|
2018-10-15 20:51:04 -04:00
|
|
|
|
|
|
|
|
|
teams = teams ?? string.Empty;
|
|
|
|
|
|
2018-10-25 09:14:39 -04:00
|
|
|
|
string assignments = Balance.GetTeamAssignments(client, isDisconnect, server, teams);
|
2018-10-15 20:51:04 -04:00
|
|
|
|
|
|
|
|
|
return Content(assignments);
|
|
|
|
|
}
|
2018-10-13 19:49:08 -04:00
|
|
|
|
}
|
|
|
|
|
}
|