source: binary-improvements2/WebServer/src/WebConnection.cs@ 406

Last change on this file since 406 was 404, checked in by alloc, 22 months ago

Latest state including reworking to the permissions system

File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Net;
4using UnityEngine;
5using Webserver.Permissions;
6
7namespace Webserver {
8 public class WebConnection : ConsoleConnectionAbstract {
9 private readonly DateTime login;
10// private readonly List<string> outputLines = new List<string> ();
11 private DateTime lastAction;
12 private readonly string conDescription;
13
14 public string SessionID { get; }
15
16 public IPAddress Endpoint { get; }
17
18 public string Username { get; }
19 public PlatformUserIdentifierAbs UserId { get; }
20 public PlatformUserIdentifierAbs CrossplatformUserId { get; }
21
22 public TimeSpan Age => DateTime.Now - lastAction;
23
24 public WebConnection (string _sessionId, IPAddress _endpoint, string _username, PlatformUserIdentifierAbs _userId, PlatformUserIdentifierAbs _crossUserId = null) {
25 SessionID = _sessionId;
26 Endpoint = _endpoint;
27 Username = _username;
28 UserId = _userId;
29 CrossplatformUserId = _crossUserId;
30 login = DateTime.Now;
31 lastAction = login;
32 conDescription = $"WebPanel from {Endpoint}";
33 }
34
35 public static bool CanViewAllPlayers (int _permissionLevel) {
36 return AdminWebModules.Instance.ModuleAllowedWithLevel ("webapi.viewallplayers", _permissionLevel);
37 }
38
39 public static bool CanViewAllClaims (int _permissionLevel) {
40 return AdminWebModules.Instance.ModuleAllowedWithLevel ("webapi.viewallclaims", _permissionLevel);
41 }
42
43 public void UpdateUsage () {
44 lastAction = DateTime.Now;
45 }
46
47 public override string GetDescription () {
48 return conDescription;
49 }
50
51 public override void SendLine (string _text) {
52// outputLines.Add (_text);
53 }
54
55 public override void SendLines (List<string> _output) {
56// outputLines.AddRange (_output);
57 }
58
59 public override void SendLog (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
60 // Do nothing, handled by LogBuffer
61 }
62 }
63}
Note: See TracBrowser for help on using the repository browser.