source: binary-improvements/MapRendering/Web/API/GetPlayerInventories.cs@ 394

Last change on this file since 394 was 369, checked in by alloc, 3 years ago

Preparations for A20 release
Changes usage of "SteamID" to "UserID" in console commands
Also changes a bunch of the WebAPI stuff to show / use UserIDs

File size: 893 bytes
Line 
1using System.Collections.Generic;
2using System.Net;
3using AllocsFixes.JSON;
4using AllocsFixes.PersistentData;
5
6namespace AllocsFixes.NetConnections.Servers.Web.API {
7 public class GetPlayerInventories : WebAPI {
8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
9 int _permissionLevel) {
10 GetPlayerInventory.GetInventoryArguments (_req, out bool showIconColor, out bool showIconName);
11
12 JSONArray AllInventoriesResult = new JSONArray ();
13
14 foreach (KeyValuePair<PlatformUserIdentifierAbs, Player> kvp in PersistentContainer.Instance.Players.Dict) {
15 Player p = kvp.Value;
16
17 if (p == null) {
18 continue;
19 }
20
21 if (p.IsOnline) {
22 AllInventoriesResult.Add (GetPlayerInventory.DoPlayer (kvp.Key.CombinedString, p, showIconColor, showIconName));
23 }
24 }
25
26 WriteJSON (_resp, AllInventoriesResult);
27 }
28 }
29}
Note: See TracBrowser for help on using the repository browser.