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

Last change on this file since 428 was 425, checked in by alloc, 19 months ago
  • API "map" added, currently only supports GET with the ID "config"
  • API "player" added, currently only supports getting online players with some of the info not supported yet (playtime, last online, level)
  • Only logged in player's data is shown unless the user has the permission for "webapi.viewallplayers"
  • Internal refactoring
  • (Updated version to 21.0.258)
File size: 1.6 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 void UpdateUsage () {
36 lastAction = DateTime.Now;
37 }
38
39 public override string GetDescription () {
40 return conDescription;
41 }
42
43 public override void SendLine (string _text) {
44// outputLines.Add (_text);
45 }
46
47 public override void SendLines (List<string> _output) {
48// outputLines.AddRange (_output);
49 }
50
51 public override void SendLog (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
52 // Do nothing, handled by LogBuffer
53 }
54 }
55}
Note: See TracBrowser for help on using the repository browser.