using System; using System.Collections.Generic; using UnityEngine; namespace AllocsFixes.NetConnections.Servers.Web { public class WebConnection : ConsoleConnectionAbstract { private readonly DateTime login; private readonly List outputLines = new List (); private DateTime lastAction; private readonly string conDescription; public WebConnection (string _sessionId, string _endpoint, ulong _steamId) { SessionID = _sessionId; Endpoint = _endpoint; SteamID = _steamId; login = DateTime.Now; lastAction = login; conDescription = "WebPanel from " + Endpoint; } public string SessionID { get; private set; } public string Endpoint { get; private set; } public ulong SteamID { get; private set; } public TimeSpan Age { get { return DateTime.Now - lastAction; } } public static bool CanViewAllPlayers (int _permissionLevel) { bool val = false; try { const int defaultPermissionLevel = 0; val = _permissionLevel <= defaultPermissionLevel; foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) { if (wap.module.Trim ().ToLower () == "webapi.viewallplayers") { val = _permissionLevel <= wap.permissionLevel; } } } catch { } return val; } public static bool CanViewAllClaims (int _permissionLevel) { bool val = false; try { const int defaultPermissionLevel = 0; val = _permissionLevel <= defaultPermissionLevel; foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) { if (wap.module.Trim ().ToLower () == "webapi.viewallclaims") { val = _permissionLevel <= wap.permissionLevel; } } } catch { } return val; } public void UpdateUsage () { lastAction = DateTime.Now; } public override string GetDescription () { return conDescription; } public override void SendLine (string _text) { outputLines.Add (_text); } public override void SendLines (List _output) { outputLines.AddRange (_output); } public override void SendLog (string _msg, string _trace, LogType _type) { // Do nothing, handled by LogBuffer } } }