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

Last change on this file since 325 was 325, checked in by alloc, 6 years ago

Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)

File size: 2.2 KB
RevLine 
[251]1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
[325]5namespace AllocsFixes.NetConnections.Servers.Web {
[251]6 public class WebConnection : ConsoleConnectionAbstract {
[325]7 private readonly DateTime login;
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) {
32 bool val = false;
[251]33
[325]34 try {
35 const int defaultPermissionLevel = 0;
[251]36
[325]37 val = _permissionLevel <= defaultPermissionLevel;
[251]38
[325]39 foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) {
40 if (wap.module.Trim ().ToLower () == "webapi.viewallplayers") {
41 val = _permissionLevel <= wap.permissionLevel;
42 }
43 }
44 } catch {
45 }
[251]46
[325]47 return val;
48 }
[251]49
[325]50 public static bool CanViewAllClaims (int _permissionLevel) {
51 bool val = false;
[251]52
[325]53 try {
54 const int defaultPermissionLevel = 0;
[251]55
[325]56 val = _permissionLevel <= defaultPermissionLevel;
[251]57
[325]58 foreach (WebPermissions.WebModulePermission wap in WebPermissions.Instance.GetModules ()) {
59 if (wap.module.Trim ().ToLower () == "webapi.viewallclaims") {
60 val = _permissionLevel <= wap.permissionLevel;
61 }
62 }
63 } catch {
64 }
[251]65
[325]66 return val;
[251]67 }
68
69 public void UpdateUsage () {
[325]70 lastAction = DateTime.Now;
[251]71 }
72
73 public override string GetDescription () {
[325]74 return conDescription;
[251]75 }
76
77 public override void SendLine (string _text) {
78 outputLines.Add (_text);
79 }
80
81 public override void SendLines (List<string> _output) {
82 outputLines.AddRange (_output);
83 }
84
85 public override void SendLog (string _msg, string _trace, LogType _type) {
86 // Do nothing, handled by LogBuffer
87 }
88 }
[325]89}
Note: See TracBrowser for help on using the repository browser.