[251] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using UnityEngine;
|
---|
| 4 |
|
---|
[325] | 5 | namespace AllocsFixes.NetConnections.Servers.Web {
|
---|
[251] | 6 | public class WebConnection : ConsoleConnectionAbstract {
|
---|
[325] | 7 | private readonly DateTime login;
|
---|
[326] | 8 | // private readonly List<string> outputLines = new List<string> ();
|
---|
[251] | 9 | private DateTime lastAction;
|
---|
[325] | 10 | private readonly string conDescription;
|
---|
[251] | 11 |
|
---|
[325] | 12 | public WebConnection (string _sessionId, string _endpoint, ulong _steamId) {
|
---|
| 13 | SessionID = _sessionId;
|
---|
| 14 | Endpoint = _endpoint;
|
---|
| 15 | SteamID = _steamId;
|
---|
| 16 | login = DateTime.Now;
|
---|
| 17 | lastAction = login;
|
---|
| 18 | conDescription = "WebPanel from " + Endpoint;
|
---|
[251] | 19 | }
|
---|
| 20 |
|
---|
[325] | 21 | public string SessionID { get; private set; }
|
---|
[251] | 22 |
|
---|
[325] | 23 | public string Endpoint { get; private set; }
|
---|
[251] | 24 |
|
---|
[325] | 25 | public ulong SteamID { get; private set; }
|
---|
| 26 |
|
---|
[251] | 27 | public TimeSpan Age {
|
---|
| 28 | get { return DateTime.Now - lastAction; }
|
---|
| 29 | }
|
---|
| 30 |
|
---|
[325] | 31 | public static bool CanViewAllPlayers (int _permissionLevel) {
|
---|
[326] | 32 | const int defaultPermissionLevel = 0;
|
---|
[251] | 33 |
|
---|
[326] | 34 | bool val = _permissionLevel <= defaultPermissionLevel;
|
---|
[251] | 35 |
|
---|
[326] | 36 | foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) {
|
---|
| 37 | if (wap.module.EqualsCaseInsensitive ("webapi.viewallplayers")) {
|
---|
| 38 | val = _permissionLevel <= wap.permissionLevel;
|
---|
[325] | 39 | }
|
---|
| 40 | }
|
---|
[251] | 41 |
|
---|
[325] | 42 | return val;
|
---|
| 43 | }
|
---|
[251] | 44 |
|
---|
[325] | 45 | public static bool CanViewAllClaims (int _permissionLevel) {
|
---|
[326] | 46 | const int defaultPermissionLevel = 0;
|
---|
[251] | 47 |
|
---|
[326] | 48 | bool val = _permissionLevel <= defaultPermissionLevel;
|
---|
[251] | 49 |
|
---|
[326] | 50 | foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) {
|
---|
| 51 | if (wap.module.EqualsCaseInsensitive ("webapi.viewallclaims")) {
|
---|
| 52 | val = _permissionLevel <= wap.permissionLevel;
|
---|
[325] | 53 | }
|
---|
| 54 | }
|
---|
[251] | 55 |
|
---|
[325] | 56 | return val;
|
---|
[251] | 57 | }
|
---|
| 58 |
|
---|
| 59 | public void UpdateUsage () {
|
---|
[325] | 60 | lastAction = DateTime.Now;
|
---|
[251] | 61 | }
|
---|
| 62 |
|
---|
| 63 | public override string GetDescription () {
|
---|
[325] | 64 | return conDescription;
|
---|
[251] | 65 | }
|
---|
| 66 |
|
---|
| 67 | public override void SendLine (string _text) {
|
---|
[326] | 68 | // outputLines.Add (_text);
|
---|
[251] | 69 | }
|
---|
| 70 |
|
---|
| 71 | public override void SendLines (List<string> _output) {
|
---|
[326] | 72 | // outputLines.AddRange (_output);
|
---|
[251] | 73 | }
|
---|
| 74 |
|
---|
| 75 | public override void SendLog (string _msg, string _trace, LogType _type) {
|
---|
| 76 | // Do nothing, handled by LogBuffer
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
[325] | 79 | }
|
---|