source: binary-improvements/MapRendering/Web/WebConnection.cs@ 292

Last change on this file since 292 was 253, checked in by alloc, 9 years ago

Fixes 6_8_10

File size: 2.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using AllocsFixes.NetConnections.Servers.Web;
4using UnityEngine;
5
6namespace AllocsFixes.NetConnections.Servers.Web
7{
8 public class WebConnection : ConsoleConnectionAbstract {
9 private string sessionId;
10 private string endpoint;
11 private ulong steamId;
12 private DateTime login;
13 private DateTime lastAction;
14 private List<string> outputLines = new List<string> ();
15
16 public string SessionID {
17 get { return sessionId; }
18 }
19
20 public string Endpoint {
21 get { return endpoint; }
22 }
23
24 public ulong SteamID {
25 get { return steamId; }
26 }
27
28 public TimeSpan Age {
29 get { return DateTime.Now - lastAction; }
30 }
31
32 public static bool CanViewAllPlayers (int _permissionLevel) {
33 bool val = false;
34
35 try {
36 const int defaultPermissionLevel = 0;
37
38 val = _permissionLevel <= defaultPermissionLevel;
39
40 foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ())
41 if (wap.module.Trim ().ToLower () == "webapi.viewallplayers")
42 val = _permissionLevel <= wap.permissionLevel;
43 }
44 catch { }
45
46 return val;
47 }
48
49 public static bool CanViewAllClaims (int _permissionLevel) {
50 bool val = false;
51
52 try {
53 const int defaultPermissionLevel = 0;
54
55 val = _permissionLevel <= defaultPermissionLevel;
56
57 foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ())
58 if (wap.module.Trim ().ToLower () == "webapi.viewallclaims")
59 val = _permissionLevel <= wap.permissionLevel;
60 }
61 catch { }
62
63 return val;
64 }
65
66 public WebConnection (string _sessionId, string _endpoint, ulong _steamId) {
67 this.sessionId = _sessionId;
68 this.endpoint = _endpoint;
69 this.steamId = _steamId;
70 this.login = DateTime.Now;
71 this.lastAction = this.login;
72 }
73
74 public void UpdateUsage () {
75 this.lastAction = DateTime.Now;
76 }
77
78 public override string GetDescription () {
79 return "WebPanel from " + endpoint;
80 }
81
82 public override void SendLine (string _text) {
83 outputLines.Add (_text);
84 }
85
86 public override void SendLines (List<string> _output) {
87 outputLines.AddRange (_output);
88 }
89
90 public override void SendLog (string _msg, string _trace, LogType _type) {
91 // Do nothing, handled by LogBuffer
92 }
93
94 }
95}
96
Note: See TracBrowser for help on using the repository browser.