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

Last change on this file since 348 was 348, checked in by alloc, 6 years ago

Fixed #156

File size: 886 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
11 bool showIconColor, showIconName;
12 GetPlayerInventory.GetInventoryArguments (_req, out showIconColor, out showIconName);
13
14 JSONArray AllInventoriesResult = new JSONArray ();
15
16 foreach (KeyValuePair<string, Player> kvp in PersistentContainer.Instance.Players.Dict) {
17 Player p = kvp.Value;
18
19 if (p == null) {
20 continue;
21 }
22
23 if (p.IsOnline) {
24 AllInventoriesResult.Add (GetPlayerInventory.DoPlayer (kvp.Key, p, showIconName, showIconName));
25 }
26 }
27
28 WriteJSON (_resp, AllInventoriesResult);
29 }
30 }
31}
Note: See TracBrowser for help on using the repository browser.