source: binary-improvements2/WebServer/src/WebAPI/APIs/GetPlayersLocation.cs@ 406

Last change on this file since 406 was 402, checked in by alloc, 22 months ago
  • Major refactoring
  • Using Utf8Json for (de)serialization
  • Moving APIs to REST
  • Removing dependencies from WebServer and MapRenderer to ServerFixes
File size: 2.1 KB
RevLine 
[402]1// using AllocsFixes.PersistentData;
2// using JetBrains.Annotations;
3//
4// namespace Webserver.WebAPI.APIs {
5// [UsedImplicitly]
6// public class GetPlayersLocation : AbsWebAPI {
7// public override void HandleRequest (RequestContext _context) {
8// AdminTools admTools = GameManager.Instance.adminTools;
9// PlatformUserIdentifierAbs reqUserId = _context.Connection?.UserId;
10//
11// bool listOffline = false;
12// if (_context.Request.QueryString ["offline"] != null) {
13// bool.TryParse (_context.Request.QueryString ["offline"], out listOffline);
14// }
15//
16// bool bViewAll = WebConnection.CanViewAllPlayers (_context.PermissionLevel);
17//
18// JsonArray playersJsResult = new JsonArray ();
19//
20// Players playersList = PersistentContainer.Instance.Players;
21//
22// foreach ((PlatformUserIdentifierAbs userId, Player player) in playersList.Dict) {
23// if (admTools != null) {
24// if (admTools.IsBanned (userId, out _, out _)) {
25// continue;
26// }
27// }
28//
29// if (!listOffline && !player.IsOnline) {
30// continue;
31// }
32//
33// if (!bViewAll && !player.PlatformId.Equals (reqUserId)) {
34// continue;
35// }
36//
37// JsonObject pos = new JsonObject ();
38// pos.Add ("x", new JsonNumber (player.LastPosition.x));
39// pos.Add ("y", new JsonNumber (player.LastPosition.y));
40// pos.Add ("z", new JsonNumber (player.LastPosition.z));
41//
42// JsonObject pJson = new JsonObject ();
43// pJson.Add ("steamid", new JsonString (userId.CombinedString));
44//
45// // pJson.Add("entityid", new JSONNumber (p.EntityID));
46// // pJson.Add("ip", new JSONString (p.IP));
47// pJson.Add ("name", new JsonString (player.Name));
48// pJson.Add ("online", new JsonBoolean (player.IsOnline));
49// pJson.Add ("position", pos);
50//
51// // pJson.Add ("totalplaytime", new JSONNumber (p.TotalPlayTime));
52// // pJson.Add ("lastonline", new JSONString (p.LastOnline.ToString ("s")));
53// // pJson.Add ("ping", new JSONNumber (p.IsOnline ? p.ClientInfo.ping : -1));
54//
55// playersJsResult.Add (pJson);
56// }
57//
58// WebUtils.WriteJson (_context.Response, playersJsResult);
59// }
60// }
61// }
Note: See TracBrowser for help on using the repository browser.