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