1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Net;
|
---|
4 | using UnityEngine;
|
---|
5 |
|
---|
6 | namespace Webserver {
|
---|
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 string SessionID { get; }
|
---|
14 |
|
---|
15 | public IPAddress Endpoint { get; }
|
---|
16 |
|
---|
17 | public PlatformUserIdentifierAbs UserId { get; }
|
---|
18 |
|
---|
19 | public TimeSpan Age => DateTime.Now - lastAction;
|
---|
20 |
|
---|
21 | public WebConnection (string _sessionId, IPAddress _endpoint, PlatformUserIdentifierAbs _userId) {
|
---|
22 | SessionID = _sessionId;
|
---|
23 | Endpoint = _endpoint;
|
---|
24 | UserId = _userId;
|
---|
25 | login = DateTime.Now;
|
---|
26 | lastAction = login;
|
---|
27 | conDescription = $"WebPanel from {Endpoint}";
|
---|
28 | }
|
---|
29 |
|
---|
30 | public static bool CanViewAllPlayers (int _permissionLevel) {
|
---|
31 | return WebPermissions.Instance.ModuleAllowedWithLevel ("webapi.viewallplayers", _permissionLevel);
|
---|
32 | }
|
---|
33 |
|
---|
34 | public static bool CanViewAllClaims (int _permissionLevel) {
|
---|
35 | return WebPermissions.Instance.ModuleAllowedWithLevel ("webapi.viewallclaims", _permissionLevel);
|
---|
36 | }
|
---|
37 |
|
---|
38 | public void UpdateUsage () {
|
---|
39 | lastAction = DateTime.Now;
|
---|
40 | }
|
---|
41 |
|
---|
42 | public override string GetDescription () {
|
---|
43 | return conDescription;
|
---|
44 | }
|
---|
45 |
|
---|
46 | public override void SendLine (string _text) {
|
---|
47 | // outputLines.Add (_text);
|
---|
48 | }
|
---|
49 |
|
---|
50 | public override void SendLines (List<string> _output) {
|
---|
51 | // outputLines.AddRange (_output);
|
---|
52 | }
|
---|
53 |
|
---|
54 | public override void SendLog (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
|
---|
55 | // Do nothing, handled by LogBuffer
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|