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

Last change on this file since 427 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
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 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.