1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Net; |
---|
4 | using UnityEngine; |
---|
5 | |
---|
6 | namespace AllocsFixes.NetConnections.Servers.Web { |
---|
7 | public class WebConnection : ConsoleConnectionAbstract { |
---|
8 | private readonly DateTime login; |
---|
9 | // private readonly List<string> outputLines = new List<string> (); |
---|
10 | private DateTime lastAction; |
---|
11 | private readonly string conDescription; |
---|
12 | |
---|
13 | public WebConnection (string _sessionId, IPAddress _endpoint, ulong _steamId) { |
---|
14 | SessionID = _sessionId; |
---|
15 | Endpoint = _endpoint; |
---|
16 | SteamID = _steamId; |
---|
17 | login = DateTime.Now; |
---|
18 | lastAction = login; |
---|
19 | conDescription = "WebPanel from " + Endpoint; |
---|
20 | } |
---|
21 | |
---|
22 | public string SessionID { get; private set; } |
---|
23 | |
---|
24 | public IPAddress Endpoint { get; private set; } |
---|
25 | |
---|
26 | public ulong SteamID { get; private set; } |
---|
27 | |
---|
28 | public TimeSpan Age { |
---|
29 | get { return DateTime.Now - lastAction; } |
---|
30 | } |
---|
31 | |
---|
32 | public static bool CanViewAllPlayers (int _permissionLevel) { |
---|
33 | return WebPermissions.Instance.ModuleAllowedWithLevel ("webapi.viewallplayers", _permissionLevel); |
---|
34 | } |
---|
35 | |
---|
36 | public static bool CanViewAllClaims (int _permissionLevel) { |
---|
37 | return WebPermissions.Instance.ModuleAllowedWithLevel ("webapi.viewallclaims", _permissionLevel); |
---|
38 | } |
---|
39 | |
---|
40 | public void UpdateUsage () { |
---|
41 | lastAction = DateTime.Now; |
---|
42 | } |
---|
43 | |
---|
44 | public override string GetDescription () { |
---|
45 | return conDescription; |
---|
46 | } |
---|
47 | |
---|
48 | public override void SendLine (string _text) { |
---|
49 | // outputLines.Add (_text); |
---|
50 | } |
---|
51 | |
---|
52 | public override void SendLines (List<string> _output) { |
---|
53 | // outputLines.AddRange (_output); |
---|
54 | } |
---|
55 | |
---|
56 | public override void SendLog (string _msg, string _trace, LogType _type) { |
---|
57 | // Do nothing, handled by LogBuffer |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|