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

Last change on this file since 420 was 404, checked in by alloc, 21 months ago

Latest state including reworking to the permissions system

File size: 1.9 KB
RevLine 
[391]1using System;
2using System.Collections.Generic;
3using System.Net;
4using UnityEngine;
[404]5using Webserver.Permissions;
[391]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
[404]18 public string Username { get; }
[391]19 public PlatformUserIdentifierAbs UserId { get; }
[404]20 public PlatformUserIdentifierAbs CrossplatformUserId { get; }
[391]21
22 public TimeSpan Age => DateTime.Now - lastAction;
23
[404]24 public WebConnection (string _sessionId, IPAddress _endpoint, string _username, PlatformUserIdentifierAbs _userId, PlatformUserIdentifierAbs _crossUserId = null) {
[391]25 SessionID = _sessionId;
26 Endpoint = _endpoint;
[404]27 Username = _username;
[391]28 UserId = _userId;
[404]29 CrossplatformUserId = _crossUserId;
[391]30 login = DateTime.Now;
31 lastAction = login;
[402]32 conDescription = $"WebPanel from {Endpoint}";
[391]33 }
34
35 public static bool CanViewAllPlayers (int _permissionLevel) {
[404]36 return AdminWebModules.Instance.ModuleAllowedWithLevel ("webapi.viewallplayers", _permissionLevel);
[391]37 }
38
39 public static bool CanViewAllClaims (int _permissionLevel) {
[404]40 return AdminWebModules.Instance.ModuleAllowedWithLevel ("webapi.viewallclaims", _permissionLevel);
[391]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.