Ignore:
Timestamp:
Apr 10, 2023, 8:23:15 PM (19 months ago)
Author:
alloc
Message:
  • 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)
Location:
binary-improvements2/WebServer
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements2/WebServer/ModInfo.xml

    r423 r425  
    55        <Description value="Integrated Webserver for the Web Dashboard and server APIs" />
    66        <Author value="The Fun Pimps LLC" />
    7         <Version value="21.0.250.0" />
     7        <Version value="21.0.258.0" />
    88        <Website value="" />
    99</xml>
  • binary-improvements2/WebServer/WebServer.csproj

    r422 r425  
    112112    <Compile Include="src\Permissions\AdminApiTokens.cs" />
    113113    <Compile Include="src\Permissions\AdminWebUsers.cs" />
     114    <Compile Include="src\Permissions\PermissionUtils.cs" />
    114115    <Compile Include="src\Permissions\RegisterModules.cs" />
    115116    <Compile Include="src\UserRegistrationTokens.cs" />
     
    128129    <Compile Include="src\WebAPI\APIs\Hostile.cs" />
    129130    <Compile Include="src\WebAPI\APIs\Log.cs" />
     131    <Compile Include="src\WebAPI\APIs\Player.cs" />
    130132    <Compile Include="src\WebAPI\APIs\RegisterUser.cs" />
    131133    <Compile Include="src\WebAPI\APIs\ServerInfo.cs" />
  • binary-improvements2/WebServer/src/SSE/EventLog.cs

    r402 r425  
    44using Utf8Json;
    55using Webserver.UrlHandlers;
     6using Webserver.WebAPI;
    67
    78namespace Webserver.SSE {
     
    1920
    2021                private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
    21                         string isotime = _timestamp.ToString ("o");
    2222                        string uptime = _uptime.ToString ();
    2323
     
    3434                       
    3535                        writer.WriteRaw (jsonIsotimeKey);
    36                         writer.WriteString (isotime);
     36                        JsonCommons.WriteDateTime (ref writer, _timestamp);
    3737                       
    3838                        writer.WriteRaw (jsonUptimeKey);
  • binary-improvements2/WebServer/src/WebAPI/JsonCommons.cs

    r408 r425  
     1using System;
     2using UnityEngine;
    13using Utf8Json;
    24
     
    1921                        _writer.WriteEndObject ();
    2022                }
    21                
     23
     24                public static void WritePositionObject (ref JsonWriter _writer, Vector3 _position) {
     25                        _writer.WriteRaw (jsonKeyPositionX);
     26                        _writer.WriteSingle (_position.x);
     27                       
     28                        _writer.WriteRaw (jsonKeyPositionY);
     29                        _writer.WriteSingle (_position.y);
     30                       
     31                        _writer.WriteRaw (jsonKeyPositionZ);
     32                        _writer.WriteSingle (_position.z);
     33                       
     34                        _writer.WriteEndObject ();
     35                }
     36
     37                private static readonly byte[] jsonKeyCombinedString = JsonWriter.GetEncodedPropertyNameWithBeginObject ("combinedString");
     38                private static readonly byte[] jsonKeyPlatformId = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("platformId");
     39                private static readonly byte[] jsonKeyUserId = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("userId");
     40
     41                public static void WritePlatformUserIdentifier (ref JsonWriter _writer, PlatformUserIdentifierAbs _userIdentifier) {
     42                        if (_userIdentifier == null) {
     43                                _writer.WriteNull ();
     44                                return;
     45                        }
     46                       
     47                        _writer.WriteRaw (jsonKeyCombinedString);
     48                        _writer.WriteString (_userIdentifier.CombinedString);
     49                       
     50                        _writer.WriteRaw (jsonKeyPlatformId);
     51                        _writer.WriteString (_userIdentifier.PlatformIdentifierString);
     52                       
     53                        _writer.WriteRaw (jsonKeyUserId);
     54                        _writer.WriteString (_userIdentifier.ReadablePlatformUserIdentifier);
     55                       
     56                        _writer.WriteEndObject ();
     57                }
     58
     59                public static void WriteDateTime (ref JsonWriter _writer, DateTime _dateTime) {
     60                        _writer.WriteString (_dateTime.ToString ("o"));
     61                }
    2262        }
    2363}
  • binary-improvements2/WebServer/src/WebConnection.cs

    r404 r425  
    3333                }
    3434
    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 
    4335                public void UpdateUsage () {
    4436                        lastAction = DateTime.Now;
  • binary-improvements2/WebServer/src/WebUtils.cs

    r422 r425  
    55using System.Text;
    66using Utf8Json;
     7using Webserver.WebAPI;
    78using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
    89using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
     
    8081
    8182                        _writer.WriteRaw (jsonRawMetaServertimeKey);
    82                         _writer.WriteString (DateTime.Now.ToString ("o"));
     83                        JsonCommons.WriteDateTime (ref _writer, DateTime.Now);
    8384
    8485                        if (!string.IsNullOrEmpty (_errorCode)) {
Note: See TracChangeset for help on using the changeset viewer.